Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using nested table as in Parameter to a Procedure

itzkashiFeb 16 2018 — edited Feb 17 2018

hi ,

i have a table T1 and i want to insert multiple rows at a time through procedure using collection..i have written the code but when i trying to execute it throws error ..please advise ..

create table t1 ( id number , name varchar2(10));

create or replace PACKAGE PKG1 AS

   TYPE TAB_LIST IS TABLE OF T1%ROWTYPE;

   PROCEDURE PROC1 (p_val IN TAB_LIST);

END PKG1;

/

create or replace PACKAGE BODY PKG1 AS

PROCEDURE PROC1 (P_VAL IN TAB_LIST

                 )

    IS

  BEGIN

    FOR i IN p_val.FIRST..p_val.LAST

    LOOP

    insert  INTO T1

            (

              ID , NAME

            )

            VALUES

            (

              P_VAL(I).ID,

              p_val(i).NAME

            );

  END LOOP;

  END;

  END;

*****************************************

DECLARE

  P_VAL DL_USER.PKG1.TAB_LIST;

BEGIN

 

   P_VAL := PKG1.TAB_LIST(123,'XYZ');

END;

*********************************************

thanks in advance

This post has been answered by Solomon Yakobson on Feb 17 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2018
Added on Feb 16 2018
14 comments
2,821 views