I have an sql query that hopefully someone will have time to look at:
I want to pass a series of numbers into a procedure, ie 1,3,5,6,7,8 and then be able to use them to access a cursor.
Unfortunately, it keeps giving me an invalid number error when I try to run it.
So, I tried to pass them in as '1','2'... but still get the same error.
My procedure code is:
PROCEDURE ken_acc_sql (p_listitems IN VARCHAR2)
IS
/* Variables */
p_txt VARCHAR2 (200);
v_listid listitems.listid%TYPE; --number(10)
CURSOR listid_curs
IS
SELECT listid
FROM listitems
WHERE listitemid IN (p_listitems); -- Line 271
--WHERE listitemid IN (1,2,3,4);
BEGIN
dbms_output.put_line ('p_list = ' || p_listitems);
OPEN listid_curs;
LOOP
FETCH listid_curs INTO v_listid; -- Line 277
EXIT WHEN listid_curs%NOTFOUND;
INSERT INTO ken2 VALUES (v_listid);
END LOOP;
CLOSE listid_curs;
END ken_acc_sql;
and I have tried to run it by:
exec ken_main.ken_acc_sql('1,2,3,4')
and
exec ken_main.ken_acc_sql('''1'',''2'',''3'',''4''')
I get the error:
SQL> exec ken_main.ken_acc_sql('''1'',''2'',''3'',''4''')
p_listitems = '1','2','3','4'
begin ken_main.ken_acc_sql('''1'',''2'',''3'',''4'''); end;
*
ERROR at line 1:
ORA-01722: invalid number
ORA-06512: at "EPROJECT3.KEN_MAIN", line 271
ORA-06512: at "EPROJECT3.KEN_MAIN", line 277
ORA-06512: at line 1
I have indicated lines 271 and 277 above.
The lines before this are just other procedures within a package I have created.
If anyone could get a few minutes and point out the very silly thing I am doing, then it would be much appreciated.
I want to pass a series of numbers into a procedure, ie 1,3,5,6,7,8 and then be able to use them to access a cursor.
Unfortunately, it keeps giving me an invalid number error when I try to run it.
So, I tried to pass them in as '1','2'... but still get the same error.
My procedure code is:
PROCEDURE ken_acc_sql (p_listitems IN VARCHAR2)
IS
/* Variables */
p_txt VARCHAR2 (200);
v_listid listitems.listid%TYPE; --number(10)
CURSOR listid_curs
IS
SELECT listid
FROM listitems
WHERE listitemid IN (p_listitems); -- Line 271
--WHERE listitemid IN (1,2,3,4);
BEGIN
dbms_output.put_line ('p_list = ' || p_listitems);
OPEN listid_curs;
LOOP
FETCH listid_curs INTO v_listid; -- Line 277
EXIT WHEN listid_curs%NOTFOUND;
INSERT INTO ken2 VALUES (v_listid);
END LOOP;
CLOSE listid_curs;
END ken_acc_sql;
and I have tried to run it by:
exec ken_main.ken_acc_sql('1,2,3,4')
and
exec ken_main.ken_acc_sql('''1'',''2'',''3'',''4''')
I get the error:
SQL> exec ken_main.ken_acc_sql('''1'',''2'',''3'',''4''')
p_listitems = '1','2','3','4'
begin ken_main.ken_acc_sql('''1'',''2'',''3'',''4'''); end;
*
ERROR at line 1:
ORA-01722: invalid number
ORA-06512: at "EPROJECT3.KEN_MAIN", line 271
ORA-06512: at "EPROJECT3.KEN_MAIN", line 277
ORA-06512: at line 1
I have indicated lines 271 and 277 above.
The lines before this are just other procedures within a package I have created.
If anyone could get a few minutes and point out the very silly thing I am doing, then it would be much appreciated.