declare
type dept_table is table of dept%rowtype index by binary_integer;
dept_tb dept_table;
cursor dept_cursor is select * from dept;
begin
open dept_cursor;
fetch dept_cursor bulk collect into dept_tb;
close dept_cursor;
for i in dept_tb.first..dept_tb.last loop
dbms_output.put_line(dept_tb(i).deptno);
end loop;
end;
declare
v_dept dept%rowtype;
cursor dept_cursor is select * from dept ;
begin
open dept_cursor;
loop
fetch dept_cursor into v_dept;
exit when dept_cursor%notfound;
dbms_output.put_line('编号:'||v_dept.deptno);
end loop;
close dept_cursor;
end;
declare
dept_row dept%rowtype;
cursor dept_cursor is select * from dept;
begin
open dept_cursor;
loop
fetch dept_cursor into dept_row;
exit when dept_cursor%notfound;
dbms_output.put_line(dept_row.deptno);
end loop;
close dept_cursor;
end;
declare
type dept_table is table of dept%rowtype index by binary_integer;
dept_tb dept_table;
cursor cursor_dept is select * from dept;
begin
open cursor_dept;
fetch cursor_dept bulk collect into dept_tb;
close cursor_dept;
for i in dept_tb.first..dept_tb.last loop
dbms_output.put_line(dept_tb(i).deptno);
end loop;
end;
declare
begin
for one in (select * from dept) loop
dbms_output.put_line(one.deptno);
end loop;
end;
create or replace procedure proce_in(v_empno in emp.empno%type, v_ename out emp.ename%type)
begin
as
select ename into v_ename from emp where empno =v_empno;
return v_ename;
exception
when no_data_found then dbms_output.put_line('输入有误,请核对');
end;
转载请注明原文地址: https://ju.6miu.com/read-5129.html