1. 声明一张Index_By表,用来接收并存储DEPT表的信息,把部门号作为键,不要忘记部门号是10的倍数。使用循环从DEPT表中将所有部门信息检索到PL/SQL记录表中,然后用另一个循环来显示表中的这些信息。
执行结果为:
10, ACCOUNTING, NEW YORK
20, RESEARCH, DALLAS
30, SALES, CHICAGO
40, OPERATIONS, BOSTON
PL/SQL 过程已成功完成。
SET SERVEROUTPUT ON
declare
Type Dept_Index is table of dept%rowtype
index by binary_integer;
d Dept_Index;
Begin
for n in 1..4 loop
Select * into d(n) from dept where deptno=10*n;
end loop;
for n in 1..4 loop
dbms_output.put_line(d(n).deptno||d(n).dname||d(n).loc);
end loop;
End;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27042095/viewspace-739591/ ,如需转载,请注明出处,否则将追究法律责任。