views:

54

answers:

2

I am getting passed comma seperated values to a stored procedure in oracle. I want to treat these values as a table so that I can use them in a query like:

select * from tabl_a where column_b in (<csv values passed in>)

What is the best way to do this in 11g?

Right now we are looping through these one by one and inserting them into a gtt which I think is ineffecient.

Any pointers?

+1  A: 

Oracle does not come with a built-in tokenizer. But it is possible to roll our own, using SQL Types and PL/SQL. I have posted a sample solution in this other SO thread.

That would enable a solution like this:

select * from tabl_a 
where column_b in ( select * 
                    from table (str_to_number_tokens (<csv values passed in>)))
/
APC
but in that solution you never show what `str_to_number_tokens` looks like?
dmitry
@dmitry - Perhaps I was too subtle but there is a link embedded in the sentence "I am using a variant of Anup Pani's implementation," i.e. http://anuppani.blogspot.com/2007/07/tokenizer-in-oracle-plsql.html
APC
+1  A: 

Hi This solves exactly same problem

Ask Tom

josephj1989