Hi I have a requirement where I get list of values to a input parameter in PL/SQL procedure. The size of the input list varies which is dynamic. How to handle this requirement any help?
2 Answers
CREATE OR REPLACE PACKAGE PKG_TEST AS
TYPE X IS TABLE OF VARCHAR2(30);
PROCEDURE XYZ(Y IN X);
END PKG_TEST;
/
The type can be declared as "TABLE OF" OR "VARRAY(10)";
CREATE OR REPLACE PACKAGE BODY PKG_TEST AS
PROCEDURE XYZ(Y IN X) AS
BEGIN
FOR I IN Y.FIRST..Y.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('THE VALUE OF I IS'||Y(I));
END LOOP;
END;
END PKG_TEST;
/
DECLARE
BEGIN
PKG_TEST.XYZ('1','2','3','4');
END;
/
Comments
You could use a varchar parameter in sql, each value must be separated by a comma, something like this: 'value1,value2,value3,value4,...,'
So, you can read the values using the function split of sql
I hope that I understood your question
2 Comments
user1118468
I didn't understand your reply, I have parameters in procedure as input, but one of teh input needed to be a list.
razielx4crazy
why dont you write some of your code? The statement of your procedure and your list, maybe I'll understand