Pass a list of values โ€‹โ€‹as an input parameter to a PL / SQL procedure

Hi I have a requirement when I get a list of values โ€‹โ€‹for an input parameter in a PL / SQL procedure. The size of the input list depends on the dynamic. How to cope with this requirement any help?

+4
source share
2 answers
CREATE OR REPLACE PACKAGE PKG_TEST AS
TYPE X IS TABLE OF VARCHAR2(30);
PROCEDURE XYZ(Y IN X);
END PKG_TEST;
/

A type can be declared as "TABLE" 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( PKG_TEST.X('1','2','3','4'));
END;
/
+5
source

You can use the varchar parameter in sql, each value should be separated by a comma, something like this: 'Value1, value2, value3, value4, ...,

So you can read the values โ€‹โ€‹using split sql function

I hope I understand your question

+1

Source: https://habr.com/ru/post/1525619/


All Articles