set serveroutput on

advertisement
8
PL/SQL on csdb
You can create and run this in much the same way as the sqlplus script in part 1 of this
set of database programming presentations.
set serveroutput on
declare
v_salary DBTA.employee.salary %TYPE;
cursor emp_cursor is
select salary
from DBTA.Employee, DBTA.Department
where dno=dnumber and dname='Research';
begin
open emp_cursor;
loop
fetch emp_cursor into v_salary;
exit when emp_cursor%notfound;
dbms_output.put_line(v_salary);
end loop;
if emp_cursor%isopen then
close emp_cursor;
end if;
exception
when no_data_found then
dbms_output.put_line('No data found.');
if emp_cursor%isopen then
close emp_cursor;
end if;
end;
Download