我想在另一个类型(Oracle)中的表类型中填充null值。 我将编写代码,更容易解释问题。
DECLARE
TYPE type_1 is record (col_1 varchar2(255),
col_2 varchar2(30),
col_3 varchar2(3)
);
TYPE table_1_tbl is table of type_1;
TYPE table_2 is record (col_1 varchar2(255),
col_2 varchar2(30),
t1 table_1_tbl
);
TYPE table_2_tbl is table of table_2;
TYPE type_3 is record (col_1 varchar2(30),
col_2 VARCHAR2(19),
t2 table_2_tbl
);
TYPE table_3_tbl is table of type_3;
Obj table_3_tbl;
BEGIN
select
'value_1',
'value_2',
null
BULK COLLECT INTO
Obj
FROM dual;
END;
/
此代码产生以下结果:
Error report:
ORA-06550: line 32, column 16:
PLS-00382: expression is of wrong type
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
正如您所看到的,Oracle不会让我使用NULL值来填充" t3"我的变量的列" obj"。你们知道我怎么能这样做?
注意:我不允许在架构中编译这些类型。
答案 0 :(得分:0)
尝试以下方法:
...
BEGIN
obj := new table_3_tbl();
obj.extend(1);
obj(1).col_1 := 'value_1';
obj(1).col_2 := 'value_2';
obj(1).t2 := NULL;
END;
/