自定义类型对象之间的赋值问题

自定义类型对象之间的赋值问题

通常情况下自定义的数据类型的对象之间不能相互赋值,哪怕自定义数据类型时的语句是一样的(当然自定义数据类型的名称是不同的)。但隐式定义的记录类型的对象可以赋给具有同字段数目,且字段的数据类型也对应相同的记录类型的对象。如以下示例中放开任何一个注释都会使得过程的编译通不过。

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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值