自定义类型对象之间的赋值问题
通常情况下自定义的数据类型的对象之间不能相互赋值,哪怕自定义数据类型时的语句是一样的(当然自定义数据类型的名称是不同的)。但隐式定义的记录类型的对象可以赋给具有同字段数目,且字段的数据类型也对应相同的记录类型的对象。如以下示例中放开任何一个注释都会使得过程的编译通不过。
create table test_type(col1 NUMBER(20,2) ,col2 VARCHAR2(50));
insert into test_type values(1,'one');
insert into test_type values(2,'two');
insert into test_type values(3,'three');
commit;
CREATE OR REPLACE PROCEDURE p_test_type
IS
type c_test_type_0 IS ref cursor return test_type%rowtype;
type c_test_type_1 IS ref cursor return test_type%rowtype;
TYPE r_test_type_0 IS record (col1 NUMBER(20,2) ,col2 VARCHAR2(50));
TYPE r_test_type_1 IS record (col1 NUMBER(20,2) ,col2 VARCHAR2(50));
TYPE r_test_type_2 IS record (col1 VARCHAR2(20) ,col2 VARCHAR2(50));
v_c_test_type_0 c_test_type_0;
v_c_test_type_1 c_test_type_1;
v_r_test_type_0 r_test_type_0;
v_r_test_type_1 r_test_type_1;
v_r_test_type_2 r_test_type_2;
v_r_test_type test_type%rowtype;
BEGIN
-- v_c_test_type_0 := v_c_test_type_1;
v_c_test_type_0 := v_c_test_type_0;
v_c_test_type_1 := v_c_test_type_1;
--v_r_test_type_0 := v_r_test_type_1;
v_r_test_type_0 := v_r_test_type;
v_r_test_type_1 := v_r_test_type;
--v_r_test_type_2 := v_r_test_type;
END;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10595277/viewspace-618105/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10595277/viewspace-618105/