--复合类型:记录类型
--可以用select语句对记录变量进行赋值,只要保证记录字段与查询结果列表中的字段类型一致即可。
declare
type test_rec is record(
name varchar2(20) not null := 'chenchaoyang',
age int,
info varchar2(40));
rec_chen test_rec;
begin
rec_chen.name := 'chenchaoyang';
rec_chen.age := 27;
rec_chen.info := 'is good man';
end;
--可以用select语句对记录变量进行赋值,只要保证记录字段与查询结果列表中的字段类型一致即可。
declare
type record_type_employees is record(
empno scott.emp.empno%type,
empname scott.emp.ename%type,
empjob scott.emp.job%type
);
v_temp_record record_type_employees;
begin
select empno,ename,job into v_temp_record
from scott.emp
--注意:一个记录类型的变量保存从数据库中查询出的一行记录,若查询出了多行记录就会出现错误
where scott.emp.empno = 7369;
end;
本文介绍了PL/SQL中记录类型的定义及使用方法,包括如何声明记录类型、实例化记录变量,并通过示例展示了如何用SELECT语句为记录变量赋值。
6730

被折叠的 条评论
为什么被折叠?



