oracle復合資料型別學習五 pl sql記錄

2021-08-31 01:53:28 字數 1459 閱讀 9679

--如何使用復合資料型別

--一、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;

oracle復合資料型別學習五 pl sql記錄

如何使用復合資料型別 一 pl sql記錄 1 在select into中自定義pl sql記錄 declare 自定義記錄變數型別 type comtype record type is record id communitytype.community type id type,name com...

oracle復合資料型別

type用於定於不確定的資料型別 declare v fd change left ekp change.fd change left type v id是表name的id的資料型別 v fd change total ekp change.fd change total type begin se...

復合資料型別

復合資料型別 作用 封裝資料 多種不同型別資料存放在一起 應存放在全域性,在訪問結構體中的變數時,應用stu.id stu.name 初始化的方式 在對陣列進行初始化時 strcpy stu.name,zhangsan 在對指標進行初始化時 char name 對name進行初始化 stu.name...