I have the need to take as input a string of numbers separated by a comma, these numbers are then to be Inserted into an Oracle table along with some other information.
I have the following code to take the string and separate it into it's separate numbers, and can then do an INSERT but can not figure out how to loop around the required number of times to insert each of the entered numbers into separate rows in the Oracle table.
Can anyone help please?
DECLARE
stores VARCHAR2 (1000) := '&3';
cnt number;
BEGIN
select count(*) into cnt from (
SELECT REGEXP_SUBSTR (stores,
'[^,]+',
1,
LEVEL)
FROM DUAL
CONNECT BY REGEXP_SUBSTR (stores,
'[^,]+',
1,
LEVEL)
IS NOT NULL);
DBMS_OUTPUT.put_line ('Stores in list : ' || cnt);
END;
/