1.复合变量例子
(1)PL/SQL记录
declare
type emp_record_type
is
record(
name test.ename%type,
salary test.sal%type,
title test.job%type
);
emp_record emp_record_type;
begin
select ename,sal,job into emp_record
from test where empno=7788;
dbms_output.put_line('雇员名:'||emp_record.name);
end;
(2).PL/SQL表
declare
type ename_table_type
is
table of test.ename%type
index by binary_integer;
ename_table ename_table_type;
begin
select ename into ename_table(-1) from test
where empno=7788;
dbms_output.put_line('雇员名:'||ename_table(-1));
end;
(3)嵌套表(类似于数组)
create or replace type emp_type as object(
name varchar2(10),salary number(6,2),
hiredate date
);
create or replace type emp_array is table of emp_type;
--emp_type用于存储雇员信息,emp_array用于存储多个雇员信息.
(1)PL/SQL记录
declare
type emp_record_type
is
record(
name test.ename%type,
salary test.sal%type,
title test.job%type
);
emp_record emp_record_type;
begin
select ename,sal,job into emp_record
from test where empno=7788;
dbms_output.put_line('雇员名:'||emp_record.name);
end;
(2).PL/SQL表
declare
type ename_table_type
is
table of test.ename%type
index by binary_integer;
ename_table ename_table_type;
begin
select ename into ename_table(-1) from test
where empno=7788;
dbms_output.put_line('雇员名:'||ename_table(-1));
end;
(3)嵌套表(类似于数组)
create or replace type emp_type as object(
name varchar2(10),salary number(6,2),
hiredate date
);
create or replace type emp_array is table of emp_type;
--emp_type用于存储雇员信息,emp_array用于存储多个雇员信息.