PL/SQL Question. [message #19430] |
Sat, 16 March 2002 08:25 |
kiran
Messages: 503 Registered: July 2000
|
Senior Member |
|
|
is there a way by which I can make a IN stmt to evaluate to TRUE always
eg: If I have below query
select col1,col2 from table1;
above query gives me say 10 rows as output
I should get the above output even after using a IN stmt
select col1,col2 from table1 where col1 IN (var1);
So If I replace the var1 with some string or character which always evaluates to true
The IN usage is a necessary in my current logic .so i need the solution with using of IN stmt only.
can please somebody let me know if there is possiblity of getting the same output
with or without the IN stmt..If so what should be the value of var1 that needs to be
replaced with.
I was trying to do the above by using a subquery in the IN so that var1 is a subquery which
will evaluate into another subquery and this subquery should give out the values for the IN
stmts and this does not work probably becoz the second subquery which should have evaluated is probably not parsed at all hence the whole subquery will be treated as string hence the condition will fail to give
the reqd result which is all rows of the table.
thanks in advace
kiran
|
|
|
Re: PL/SQL Question. [message #19431 is a reply to message #19430] |
Sat, 16 March 2002 17:27 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
Well, it doesn't make much sense as a SQL statement, but I suppose the most direct way to force your IN clause to evaluate to true would be:
select col1,col2 from table1 where col1 IN (col1);
|
|
|
Re: PL/SQL Question. [message #19434 is a reply to message #19430] |
Sun, 17 March 2002 17:47 |
mahes
Messages: 1 Registered: March 2002
|
Junior Member |
|
|
if you want to get the same thing as the output then u can use this query.Only exists() statement will return tru or false.in() statement will select the rows which ever row obeys the condition in IN() operator.
select col1,col2 from table1 where col1 in(select col1 from table1)
|
|
|
Re: PL/SQL Question. [message #19446 is a reply to message #19430] |
Mon, 18 March 2002 08:42 |
Sri DHAR
Messages: 22 Registered: March 2002
|
Junior Member |
|
|
I agree with Todd,
If you need to use var1 in the SQL, a minor change to Todd's SQL
Select col1,col2 from table1 where col1 IN
decode(var1, NULL, col1, col1)
regards,
Sri
|
|
|