Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass list of values as input parameter to PL/SQL procedure

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?

like image 444
user1118468 Avatar asked Feb 06 '14 14:02

user1118468


1 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;
/
like image 133
user1118468 Avatar answered Sep 20 '22 03:09

user1118468