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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter concatenation for IN condition

Status
Not open for further replies.

sirpelon

Programmer
Sep 13, 2001
19
0
0
MX
Hi, i'd like to know if it is possible to concatenate a parameter to a IN condition, something like this

SELECT *
FROM table
WHERE column1 IN :)parameter);

*column1 is of type NUMBER
*the value of parameter VARCHAR2 could be 4,5,6,8

once interpreted should be like :

SELECT *
FROM table
WHERE column1 IN (4,5,6,8);


When i send just a number (4), it's ok, but when i send two or more number (4,5,6) the error "NUMBER INVALID" is present

If anyone has a tip on this i'd be thankful :)
 
Not explicitly, you need DYNAMIC SQL for that. Another option is to create some function that parses string parameter and returns some collection then replace your list by subquery from that procedure. But this approach needs some server pl/sql programming.

Regards, Dima
 
Instead of
Code:
WHERE column1 IN (:parameter)
use
Code:
WHERE instr(:parameter, column1)>0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top