Home » SQL & PL/SQL » SQL & PL/SQL » use select statement in decode function (oracle 11g)
use select statement in decode function [message #455417] Tue, 11 May 2010 08:34 Go to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
I am trying to use decode function in sql
and inside decode function can I use select statement ?


here is my sql
select we.wf_entity_id, decode(object_type_id, 
                                1, select audit_number from ea_audit_general where sys_audit_id=object_id
                                2,'test',
                                object_type_id
                                ) from wf_entity  we
 where
 we.entry_id in
(SELECT entry_id 
FROM os_currentstep
GROUP BY entry_id
HAVING ( COUNT(entry_id) > 1 ))


see this

decode(object_type_id, 
                                1, select audit_number from ea_audit_general where sys_audit_id=object_id
                                2,'test',
                                object_type_id
                                )

will this work ? Its not working for me is there any other option ?
Re: use select statement in decode function [message #455418 is a reply to message #455417] Tue, 11 May 2010 08:37 Go to previous messageGo to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
in simple words
I want something like this
select decode('1',select 'test' from dual ,'2','test2')  from dual

this is just to explain my problem how to use select statement inside decode function, if it is not possible is there any other way ?
Re: use select statement in decode function [message #455419 is a reply to message #455418] Tue, 11 May 2010 08:39 Go to previous message
Michel Cadot
Messages: 68757
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
SQL> select decode('1',(select 'test' from dual),'2','test2')  from dual;
DECOD
-----
test2

1 row selected.

Regards
Michel
Previous Topic: How to remove string before and after pipeline to get string between pipeline?
Next Topic: Select on DBA_DATA_FILES
Goto Forum:
  


Current Time: Tue Apr 29 07:01:13 CDT 2025