-1
declare
    TYPE stag_tab IS TABLE OF d_staging%ROWTYPE;
    stag_tab1 stag_tab; 
begin
    --Bulk Collect
    select * bulk collect into staging_tab1 from d_staging; 
    PKG_T.PROC_T(stag_tab1);
end;
/

Package definition:

--Package 
CREATE OR REPLACE PACKAGE PKG_T 
AS 
  TYPE staging IS TABLE OF d_staging%ROWTYPE; 
  PROCEDURE PROC_T(p_staging IN staging); 
END PKG_T; 
/

-- Package Body
CREATE OR REPLACE PACKAGE BODY PKG_T
AS
  PROCEDURE PROC_T (p_staging IN staging) 
  AS 
     VAR1 d_staging%ROWTYPE; 
     CUR1 SYS_REFCURSOR; 
     QUERY_STRING VARCHAR2(2000); 
  BEGIN 
    OPEN CUR1 FOR SELECT * from table(p_staging); 
    LOOP 
      FETCH CUR1 into VAR1; 
      EXIT WHEN cur1%NOTFOUND; 
      INSERT into d (testdata) VALUES (var1.testval1); 
      COMMIT; 
    END LOOP; 
  END; 
END PKG_T;
/
Sujitmohanty30
  • 3,256
  • 2
  • 5
  • 23

2 Answers2

1

You are receiving the error because the procedure PKG_T.PROC_T is expecting a parameter of type staging, but when you are calling the procedure you are passing it a variable of type stag_tab. The type of the variable being passed to the procedure needs to match the type of the parameter definition for the procedure.

EJ Egyed
  • 5,791
  • 1
  • 8
  • 23
1

Your procedure declaration:

PROCEDURE PROC_T (p_staging IN staging) 

Takes the argument as type staging.

You are passing the argument as a locally defined type:

TYPE stag_tab IS TABLE OF d_staging%ROWTYPE;

These are different types. Instead, you need the PL/SQL block to be:

declare
    stag_tab1 package_name.staging; 
begin
    select *
    bulk collect into stag_tab1
    from d_staging; 

    PKG_T.PROC_T(stag_tab1);
end;
/
MT0
  • 143,790
  • 11
  • 59
  • 117