I am writing a stored procedure that needs an WHERE IN clause with an array of numbers. How can I pass this array of numbers to the SP. What I thought is sending a string like '123,234,345' and than parse it in the SP before using it. Is this a good way of doing it? If yes, how can I make the below code work?
CREATE OR REPLACE PROCEDURE sp_test2
(
ids in varchar2,
cursor_ OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN cursor_ FOR
SELECT *FROM my_table
WHERE my_table.ID IN (
SELECT regexp_substr(ids,'[^:]+', 1, level) AS list FROM dual
CONNECT BY regexp_substr(ids, '[^:]+', 1, level) IS NOT NULL);
END;
/
For example (instead of the conversion code) when use like this: IN(ids) i get ORA-01722: invalid number error