I am looking for something like below for the purpose of accepting array variables from the user itself, I know the below code is wrong, but it is just for the sake of giving the idea of my requirement.
DECLARE
type names_array IS VARRAY(5) OF VARCHAR2(10);
names names_array;
BEGIN
FOR i in 1..5 LOOP
accept names(i);
END LOOP;
FOR j in 1 .. 5 LOOP
dbms_output.put_line(names(j));
END LOOP;
END;
/
It will be difficult to implement using PL/SQL.But we could using substitution variables in SQL Plus.
I create two sql scripts: the first is main.sql and another is script_insert.sql:
Next we should create a table other than using an array:
Now, we could execute it:
We got it,you should using a table other than array because only PL/SQL support it.And you shouldn't using substitution variables in loop! The finally, why don't you implement this by C/Python/Java in your program?If so, you'll be more relaxed.
Refer:How to create a menu in SQLPlus or PL/SQL