- 1 记录类型变量定义
- <PL/SQL变量名><数据库>.<列名>% type
- set serveroutput on;
- declare
- type stuInfo_record is record(
- --用%type定义与stuInfo表字段相匹配的变量类型
- temp_stuName stuInfo.stuName% type,
- temp_stuNo stuInfo.stuNo% type,
- temp_stuSex stuInfo.stuSex% type,
- temp_stuAge stuInfo.stuAge% type,
- temp_stuSeat stuInfo.setSext% type,
- temp_stuAddress stuInfo.stuAddress % type);
- --声明接收数据的变量
- emp_record stuInfo_record;
- begin
- select * from into stuInfo where stuName='mark';
- dbms_output_line(emp_record.temp_stuName || emp_record.temp_stuNo);
- end;
- 2 表类型变量定义
- set serveroutput on;
- declare
- type stuInfo is table of char(8) index by binary_integer;
- emp_stuInfo stuInfo;
- i binary_integer:=0;
- begin
- for recinfor in(select stuName for StuInfo)loop
- i:=i+1;
- emp_stuInfo(i):recinfor.stuName;
- end loop;
- end;
- 3 记录类型变量定义
- <PL/SQL变量名><数据库>.<列名>% rowtype
- declare rec_infor stuInfo%rowtype;
- --rec_infor与stuInfo表的每个行的结构类型完全相同
- begin
- select * into rec_infor from stuInfo stuName='mark';
- dmbs_output_line('姓名'+||rec_infor.stuName);
- end;
Oracle 复杂数据类型
最新推荐文章于 2017-06-28 11:28:22 发布