Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> IN LIST in PL/SQL
I have some anonymous PL/SQL in the below I am testing for a routine
eventually to be called from C# application. I am trying to build an
IN list in a variable as the below shows and it is not taking it.
I take a string '04,06,08' and try to get it to work as select * from t_table where b IN (V_VARIABLE);
It only works when I hard code the variables. My next step is to look at the 9i pipeline functions if the below or something close will not work.
connect /
set serveroutput on
DECLARE
i_VAR varchar2(10);
o_concat varchar2(20);
TABX ora_util.string_array;
v_a t_table.a%TYPE; v_b t_table.b%TYPE; v_o number;
BEGIN
i_var := '04,06,08';
ora_util.delimited_string_to_array(i_var,',',TABX);
FOR I IN TABX.FIRST..TABX.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('vars=' || TABX(i));
o_concat := o_concat||chr(39)||tabx(i)||chr(39)||',';
--
OPEN xio_cursor FOR
SELECT * FROM T_TABLE WHERE B IN (o_concat);