cursor13.txt - SQL> set serverout on SQL> declare 2 no number(4 3 empno number(6 4 name varchar2(20 5 cursor curs is select empno from emp4 6 begin 7

cursor13.txt - SQL> set serverout on SQL> declare 2 no...

This preview shows page 1 - 4 out of 26 pages.

SQL> set serverout on; SQL> declare 2 no number(4); 3 empno number(6); 4 name varchar2(20); 5 cursor curs is select empno from emp4; 6 begin 7 open curs; 8 if curs %isopen then 9 loop 10 no :=&empno; 11 update emp4 set sal=sal+1000 where empno =no; 12 fetch curs into name; 13 exit when curs %notfound; 14 end loop; 15 commit; 16 else 17 dbms_output.put_line('unable to open cursor'); 18 end if; 19 close curs; 20 exception 21 when value_error then 22 dbms_output.put_line('employee number is greater than 5 digits'); 23 end; 24 / Enter value for empno: 8000 old 10: no :=&empno; new 10: no :=8000; PL/SQL procedure successfully completed. SQL> declare 2 no number(4); 3 empno number(6); 4 name varchar2(20); 5 cursor curs is select empno from emp4; 6 begin 7 open curs; 8 if curs %isopen then 9 loop 10 no :=&empno; 11 update emp4 set sal=sal+1000 where empno =no; 12 fetch curs into name; 13 exit when curs %notfound; 14 end loop; 15 commit; 16 else 17 dbms_output.put_line('unable to open cursor'); 18 end if; 19 close curs; 20 exception 21 when value_error then 22 dbms_output.put_line('employee number is greater than 5 digits'); 23 end; 24 / Enter value for empno: 456778 old 10: no :=&empno; new 10: no :=456778; employee number is greater than 5 digits PL/SQL procedure successfully completed. SQL> declare 2 no number(4);
Image of page 1
3 empno number(6); 4 name varchar2(20); 5 cursor curs is select empno from emp4; 6 begin 7 open curs; 8 if curs %isopen then 9 loop 10 no :=&empno; 11 update emp4 set sal=sal+1000 where empno =no; 12 fetch curs into name; 13 exit when curs %notfound; 14 end loop; 15 commit; 16 else 17 dbms_output.put_line('unable to open cursor'); 18 end if; 19 close curs; 20 exception 21 when value_error then 22 dbms_output.put_line('employee number is greater than 5 digits'); 23 end; 24 / Enter value for empno: 8002 old 10: no :=&empno; new 10: no :=8002; PL/SQL procedure successfully completed. SQL> declare 2 no number(4); 3 empno number(6); 4 name varchar2(20); 5 cursor curs is select empno from emp4; 6 begin 7 open curs; 8 if curs %isopen then 9 loop 10 no :=&empno; 11 update emp4 set sal=sal+1000 where empno =no; 12 fetch curs into name; 13 exit when curs %notfound; 14 end loop; 15 commit; 16 else 17 dbms_output.put_line('unable to open cursor'); 18 end if; 19 close curs; 20 exception 21 when value_error then 22 dbms_output.put_line('employee number is greater than 5 digits'); 23 end; 24 / Enter value for empno: 34567 old 10: no :=&empno; new 10: no :=34567; employee number is greater than 5 digits PL/SQL procedure successfully completed. SQL> declare 2 no number(4); 3 empno number(6); 4 name varchar2(20); 5 cursor curs is select empno from emp4;
Image of page 2
6 begin 7 open curs; 8 if curs %isopen then 9 loop 10 no :=&empno; 11 update emp4 set sal=sal+1000 where empno =no; 12 select sal from emp4; 13 dbms_output.put_line('new salary'||sal); 14 fetch curs into no; 15 exit when curs %notfound; 16 end loop; 17 commit; 18 else 19 dbms_output.put_line('unable to open cursor'); 20 end if; 21 close curs; 22 exception 23 when value_error then 24 dbms_output.put_line('employee number is greater than 5 digits'); 25 end; 26 27 28 29 / Enter value for empno: 8001 old 10: no :=&empno; new 10: no :=8001; select sal from emp4; * ERROR at line 12: ORA-06550: line 12, column 1: PLS-00428: an INTO clause is expected in this SELECT statement ORA-06550: line 13, column 36:
Image of page 3

Want to read all 26 pages?

Image of page 4

Want to read all 26 pages?

You've reached the end of your free preview.

Want to read all 26 pages?

  • Summer '14

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture