7

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 2

10
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;
/
Sign up to request clarification or add additional context in comments.

Comments

2

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

I didn't understand your reply, I have parameters in procedure as input, but one of teh input needed to be a list.
why dont you write some of your code? The statement of your procedure and your list, maybe I'll understand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.