複合變數【PL/SQL】
阿新 • • 發佈:2019-01-09
1. PL/SQL記錄(相當於高階語言中的結構體)
declare --定義記錄型別 type emp_record_type is record( ename emp.ename%type, salary emp.sal%type, title emp.job%type); --定義變數 ch_record emp_record_type; begin --執行部分 select ename,sal,job into ch_record from emp where empno=7788; dbms_output.put_line('員工名:'||ch_record.ename); end;
2. PL/SQL表(相當於高階語言中的陣列,但是表元素的下標沒有限制)
declare
--定義型別
type ch_table_type is table of emp.ename%type
index by binary_integer;
--定義變數
ch_table ch_table_type;
begin
--執行部分
select ename into ch_table(0) from emp where empno=7788;
dbms_output.put_line('員工名:'||ch_table(0));
end;
3.巢狀表
4. varray【變長陣列】