Home » SQL & PL/SQL » SQL & PL/SQL » Variable in select "IN" clause (merged)
Variable in select "IN" clause (merged) [message #359213] Fri, 14 November 2008 03:01 Go to next message
visva
Messages: 3
Registered: November 2008
Location: Malaysia
Junior Member
I have a scenario like the one below.

BEGIN
OPEN cv_1 FOR

SELECT Cal1, col2 col3
FROM Employee
where
EmployeeType In (Select TypeID from Table);

END

I want to change the "Select TypeID from Table" into a variable like "ABC". How do I write it in procedure?
The "Select TypeID from Table" will return multiple rows
Re: Variable in select "IN" clause (merged) [message #359219 is a reply to message #359213] Fri, 14 November 2008 03:15 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What ABC should contain? A list of values or the statement? It is not clear.

Also search for "varying in list" or the like, this has been addressed several times.

Regards
Michel
Re: Variable in select "IN" clause (merged) [message #359221 is a reply to message #359213] Fri, 14 November 2008 03:24 Go to previous messageGo to next message
visva
Messages: 3
Registered: November 2008
Location: Malaysia
Junior Member
"ABC" should contain TypeID . That select statement returns multiple rows
Re: Variable in select "IN" clause (merged) [message #359223 is a reply to message #359213] Fri, 14 November 2008 03:26 Go to previous messageGo to next message
visva
Messages: 3
Registered: November 2008
Location: Malaysia
Junior Member
If "select TypeID from table" returns,
"12,13,14,15,16" then the variable should hold that stream of data.
Re: Variable in select "IN" clause (merged) [message #359224 is a reply to message #359213] Fri, 14 November 2008 03:29 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member


Please refer Variable In List

Smile
Rajuvan
Re: Variable in select "IN" clause (merged) [message #359230 is a reply to message #359223] Fri, 14 November 2008 04:23 Go to previous message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why don't you want to keep your first query?
Note that usual way to use a variable in string list is to convert it to a table. If you comes from a table there is no benefit to convert it to a string list.

Regards
Michel
Previous Topic: Single ROW Query - but not all columns
Next Topic: DELETE
Goto Forum:
  


Current Time: Fri Dec 09 17:24:54 CST 2016

Total time taken to generate the page: 0.20072 seconds