Oracle 复杂数据类型

  1. 1 记录类型变量定义
  2. <PL/SQL变量名><数据库>.<列名>% type
  3. set serveroutput on;
  4. declare 
  5. type stuInfo_record is record(
  6.     --用%type定义与stuInfo表字段相匹配的变量类型
  7.     temp_stuName stuInfo.stuName% type,
  8.     temp_stuNo stuInfo.stuNo% type,
  9.     temp_stuSex stuInfo.stuSex% type,
  10.     temp_stuAge stuInfo.stuAge% type,
  11.     temp_stuSeat stuInfo.setSext% type,
  12.     temp_stuAddress stuInfo.stuAddress % type);
  13.     --声明接收数据的变量
  14.     emp_record stuInfo_record;
  15. begin
  16.     select * from into stuInfo where stuName='mark';
  17.     dbms_output_line(emp_record.temp_stuName || emp_record.temp_stuNo);
  18. end;
  19. 2 表类型变量定义
  20. set serveroutput on;
  21. declare
  22.     type stuInfo is table of char(8) index by binary_integer;
  23.     emp_stuInfo stuInfo;
  24.     i binary_integer:=0;
  25. begin
  26.     for recinfor in(select stuName for StuInfo)loop
  27.             i:=i+1;
  28.             emp_stuInfo(i):recinfor.stuName;
  29.     end loop;
  30. end;
  31. 3 记录类型变量定义
  32. <PL/SQL变量名><数据库>.<列名>% rowtype
  33. declare rec_infor stuInfo%rowtype;
  34.     --rec_infor与stuInfo表的每个行的结构类型完全相同
  35. begin
  36.     select * into rec_infor from stuInfo stuName='mark';
  37.     dmbs_output_line('姓名'+||rec_infor.stuName);
  38. end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值