select * FROM TABLE(fun_test_1) ;
ORA-06530: 引用未初始化的组合
ORA-06512: 在 "PCISS.FUN_TEST_1", line 10
SQL>
---抛错代码
1 CREATE OR REPLACE TYPE table_test2 IS OBJECT(
2 SID INTEGER ,
3 sname VARCHAR2(50),
4 age INT ,
5 sex varchar2(2),
6 addres Varchar2(100)
7 );
9 CREATE OR REPLACE TYPE typ_test2_table IS TABLE OF table_test2 ;
11 CREATE OR REPLACE FUNCTION fun_test_1 RETURN typ_test2_table PIPELINED AS
12 rec_test2 test2%ROWTYPE ;
13 tab_test2 table_test2 ;
14 BEGIN
15 SELECT * INTO rec_test2 FROM test2 t WHERE t.sid=1 ;
16 tab_test2.sid := rec_test2.sid ;
17 tab_test2.sname := rec_test2.sname ;
18 tab_test2.age := rec_test2.age ;
19 tab_test2.sex := rec_test2.sex ;
20 tab_test2.addres := rec_test2.addres ;
21 PIPE ROW(tab_test2);
22 RETURN ;
23 end fun_test_1;
24 /
---抛错原因;
1 CREATE OR REPLACE FUNCTION FUN_TEST_1 RETURN TYP_TEST2_TABLE
2 PIPELINED AS
3 REC_TEST2 TEST2%ROWTYPE;
4 TAB_TEST2 TABLE_TEST2 /* := TABLE_TEST2(NULL, NULL, NULL, NULL, NULL)*/
6 CURSOR CUR IS
7 SELECT E.EMPNO, E.ENAME, E.DEPTNO, 'na', E.JOB FROM EMP E;
8 BEGIN
9 SELECT * INTO REC_TEST2 FROM TEST2 T WHERE T.SID = 1;
10 TAB_TEST2.SID := REC_TEST2.SID;
11 TAB_TEST2.SNAME := REC_TEST2.SNAME;
12 TAB_TEST2.AGE := REC_TEST2.AGE;
13 TAB_TEST2.SEX := REC_TEST2.SEX;
14 TAB_TEST2.ADDRES := REC_TEST2.ADDRES;
15 PIPE ROW(TAB_TEST2);
17 TAB_TEST2.SID := 7788;
18 TAB_TEST2.SNAME := 'admin';
19 TAB_TEST2.AGE := 21;
20 TAB_TEST2.SEX := '男';
21 TAB_TEST2.ADDRES := '上海';
22 PIPE ROW(TAB_TEST2);
24 OPEN CUR;
25 LOOP
26 FETCH CUR
27 INTO TAB_TEST2.SID,
28 TAB_TEST2.SNAME,
29 TAB_TEST2.AGE,
30 TAB_TEST2.SEX,
31 TAB_TEST2.ADDRES;
33 EXIT WHEN CUR%NOTFOUND;
34 PIPE ROW(TAB_TEST2);
35 END LOOP;
36 close cur ;
37 RETURN;
38 END FUN_TEST_1;