oracle11g - In Oracle Stored Procedure I am passing parameter as String to check the IN condition. This is not yielding results -


pincon passing ('1','2')

create or replace procedure proc1 (  pincon in varchar2,       p_recordset out sys_refcursor   )  begin         open    p_recordset      select col1,col2     table1     col1 in pincon;         end  proc1;  

but when select, seeing values. pls help

assuming intention pass in multiple values rather single string contains single quotes, commas, etc. best option pass in actual collection. like

create type num_table    table of number;  create or replace procedure proc1( p_in in num_table,                                    p_recordset out sys_refcursor ) begin   open p_recordset     select col1, col2          table1         col1 in (select column_value table( p_in )); end; 

if need pass in string of comma-separated values rather collection, parse string passed in collection in stored procedure. tom kyte has canonical post on handling variable in lists walks through approach.

it possible use dynamic sql. has numerous downsides, though. slower, makes other things running in database slower flooding shared pool non-sharable statements, introduces potential sql injection attacks, etc.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -