0% found this document useful (0 votes)
10 views1 page

SQL Cursors

The document provides examples of implicit and explicit cursors in PL/SQL. The implicit cursor example updates salaries for a department and outputs the number of rows updated. The explicit cursor example selects employee IDs and names, outputs 10 records, and closes the cursor.

Uploaded by

MANNAM SARAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

SQL Cursors

The document provides examples of implicit and explicit cursors in PL/SQL. The implicit cursor example updates salaries for a department and outputs the number of rows updated. The explicit cursor example selects employee IDs and names, outputs 10 records, and closes the cursor.

Uploaded by

MANNAM SARAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

implicit:

declare
2 cnt number(3);
3 begin
4 update employees set salary= salary+2 where department_id=20;
5 cnt:= SQL%RowCount;
6 dbms_output.put_line(cnt|| ' rows updated');
7 end;
8 /
2 rows updated

explicit

declare
2 v_empid employees.employee_id%TYPE;
3 v_empname employees.first_name%TYPE;
4 cursor emp_cursor IS
5 select employee_id,first_name from employees;
6 begin
7 open emp_cursor;
8 loop
9 fetch emp_cursor into v_empid,v_empname;
10 exit when emp_cursor%ROWCOUNT>10 or emp_cursor%NOTFOUND;
11 dbms_output.put_line(v_empid|| ':'||v_empname);
12 end loop;
13 close emp_cursor;
14 end;
15 /
174:Ellen
166:Sundar
130:Mozhe
105:David
204:Hermann
116:Shelli
167:Amit
172:Elizabeth
192:Sarah
151:David

You might also like