Discussion:
most preferable SQL
(too old to reply)
A***@gmail.com
2007-02-08 13:51:02 UTC
Permalink
Which is most preferable between the below SQLs? In terms of consuming
resources or fast execution.

1. Update Table1 set Reason = 'SX#' where
(Sex <> 'M' or
Sex <> 'F' or
trim(Sex) <> '') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;

2. Update Table1 set Reason = 'SX#' where
(Sex not in ( 'M', 'F','') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;

I am calling this SQL in the stored procedure. If there is another
better way of writing SQL for the above query, please let me know.

Thanks in advance.

Amrith
A***@gmail.com
2007-02-08 14:35:37 UTC
Permalink
Post by A***@gmail.com
Which is most preferable between the below SQLs? In terms of consuming
resources or fast execution.
1. Update Table1 set Reason = 'SX#' where
(Sex <> 'M' or
Sex <> 'F' or
trim(Sex) <> '') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;
2. Update Table1 set Reason = 'SX#' where
(Sex not in ( 'M', 'F','') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;
I am calling this SQL in the stored procedure. If there is another
better way of writing SQL for the above query, please let me know.
Thanks in advance.
Amrith
Sorry. If I use 'and' instead of 'or which query is efficient?

1. Update Table1 set Reason = 'SX#' where
(Sex <> 'M' and
Sex <> 'F' and
trim(Sex) <> '') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;

2. Update Table1 set Reason = 'SX#' where
Sex not in ( 'M', 'F','') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;

Thanks!
DA Morgan
2007-02-08 16:20:13 UTC
Permalink
Post by A***@gmail.com
Post by A***@gmail.com
Which is most preferable between the below SQLs? In terms of consuming
resources or fast execution.
1. Update Table1 set Reason = 'SX#' where
(Sex <> 'M' or
Sex <> 'F' or
trim(Sex) <> '') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;
2. Update Table1 set Reason = 'SX#' where
(Sex not in ( 'M', 'F','') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;
I am calling this SQL in the stored procedure. If there is another
better way of writing SQL for the above query, please let me know.
Thanks in advance.
Amrith
Sorry. If I use 'and' instead of 'or which query is efficient?
1. Update Table1 set Reason = 'SX#' where
(Sex <> 'M' and
Sex <> 'F' and
trim(Sex) <> '') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;
2. Update Table1 set Reason = 'SX#' where
Sex not in ( 'M', 'F','') and
Key = inKey And
Sub_Key = inSubKey and
Reason is NULL;
Thanks!
1. c.d.o.marketplace is not for technical questions. Please post at
c.d.o.server.

2. No one can answer the question you asked: Try it!

But I must confess to fascination. What genders are there other than M,
F, and what I presume you mean to be NULL (which you should state as
such since Oracle is NOT SQL Server).
--
Daniel A. Morgan
University of Washington
***@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Continue reading on narkive:
Loading...