开发者

ORA-06530: Reference to uninitialized composite

When I am executing the package I get an error message:

error in the emp_test ORA-06530: Reference to uninitialized composite

Can u explain how I can initialized an object type in a package?

CREATE OR REPLACE TYPE emp_obj AS OBJECT
(
  emp_no   number,
  salary   number,
  job   varchar2(20)
);

CREATE OR REPLACE PACKAGE BODY emp_dummy_pk IS
  PROCEDURE emp_test IS
    CURSOR emp_cur IS
      SELECT empno, sal, job FROM emp;

    l开发者_Go百科_emp_no  emp_obj;
  BEGIN
    FOR emp_rec IN emp_cur LOOP
      l_emp_no.emp_no := emp_rec.empno;
      l_emp_no.salary := emp_rec.sal;
      l_emp_no.job := emp_rec.job;

      BEGIN
        emp_pk.emp_chk( p_emp_no => l_emp_no );
      EXCEPTION
        WHEN OTHERS THEN
          dbms_output.put_line( 'error in the emp_pk.emp_no ' || SQLERRM );
      END;
    END LOOP;
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line( 'error in the emp_test ' || SQLERRM );
  END;
END;

BEGIN
  emp_dummy_pk.emp_test;
END;


You can initialize it using the constructor:

l_emp_no := NEW emp_obj( emp_rec.empno, emp_rec.sal, emp_rec.job );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜