Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query problem

Status
Not open for further replies.

urchin556

IS-IT--Management
Mar 14, 2004
22
US
Hi Friends,
In my sql script i am running the following query and
if the condition matches i want to run the query inside decode.How its is possible??
select decode(1,1,'select version_no from sit_version;', null) query_result from dual;
 
Urchin,

Your query means, "If 1 = 1, then select version_no from sit_version;". Since 1 = 1 as long as I've been alive, why not just say, 'select version_no from sit_version;'?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 06:46 (02Jul04) UTC (aka "GMT" and "Zulu"), 23:46 (01Jul04) Mountain Time)
 
actually it will be a variable instead of 1.I had just given so that easy to understand..it will be like this
select decode(&nu,1,'select * from sit_version;',null) from dual;
 
Then how about:
Code:
select * from sit_version
where &nu = 1;

...since decode does not let you use a SELECT statement as an argument of a DECODE statement.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 06:53 (02Jul04) UTC (aka "GMT" and "Zulu"), 23:53 (01Jul04) Mountain Time)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top