PL/SQL中的变量

1.标量:

ag1:

declare 

v_ename emp.ename%type;--自己称为单变量

begin

select ename into v_ename from emp where empno=&no;

dbms_output.put_line('雇员名称'||v_ename);

end;

ag2:

declare

type test1 is record(t1 emp.ename%type,t2 emp.sal%type);--定义记录型变量

v_tt test1;--v_tt为复合型变量test1

begin

select ename,sal  into v_tt from emp where empno=&no;

dbms_output.put_line('雇员姓名'||v_tt.t1||' 薪资'||v_tt.t2);

end;

ag3:

declare 

type test2 is table  of emp.ename%type index by binary_integer;--PL/SQL 表类型

v_ename test2;

begin

select ename into v_ename(0) from emp where empno=7788;

dbms_output.put_line('雇员姓名:'||v_ename(0));

end;

你可能感兴趣的:(pl/sql)