Oracle 自定義結構(Record)



1、概念及使用

     類似於C中的自定義類型,可用於定義某表的字段集合。 

       定義格式  type recordName is Record(
                         字段名稱 字段類型,
                         字段名稱 字段類型
                     );

       使用步驟: 1)聲明結構體   2)定義結構體變量 3)使用。

2、例:

--在匿名塊中使用record,也可定義在過程、函數、包中。
declare
--聲明結構體
type re_stu is record(
rname student.name%type, --中間用逗號分開
rage student.age%type --最后一個字段沒有符號
); --以分號結束
--定義結構體變量
rw_stu re_stu;
cursor c_stu is select name,age from student;
begin
open c_stu;
loop
fetch c_stu into rw_stu; --使用結構體變量
exit when c_stu%notfound;
dbms_output.put_line('姓名='||rw_stu.rname||' 年齡='||rw_stu.rage);
end loop;
close c_stu;
end;



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM