您的位置:首页 > 数据库 > Oracle

oracle复合数据类型学习五——pl/sql记录

2014-10-30 11:30 816 查看
--如何使用复合数据类型
--一、pl/sql记录
--1、在select into中自定义pl/sql记录
declare
-- 自定义记录变量类型
type comtype_record_type is record(
id communitytype.community_type_id%type,
name communitytype.name%type
);
--自定义变量
comtype_record comtype_record_type;
begin
select ct.community_type_id,ct.name into comtype_record
from communitytype ct
where ct.community_type_id = 'ebook';
dbms_output.put_line(comtype_record.name);
end;
--2、在select into中自定义pl/sql记录
declare
-- 自定义记录变量类型
type comtype_record_type is record(
id communitytype.community_type_id%type,
name communitytype.name%type
);
--自定义变量
comtype_record comtype_record_type;
begin
select ct.community_type_id,ct.name into comtype_record.id,comtype_record.name
from communitytype ct
where ct.community_type_id = 'ebook';
dbms_output.put_line(comtype_record.name);
end;
--2、在insert中自定义pl/sql记录
declare
comtype_record communitytype%type;
begin
comtype_record.community_type_id:='wlcb';
comtype_record.name:='网络出版';
from communitytype ct
insert into communitytype values comtype_record;
--或者insert into communitytype(community_type_id,name)
--values (comtype_record.community_type_id,comtype_record.name);
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: