lecture-6-1
lecture-6-1
lecture-6-1
Lecture 6
•A Concept of Cursor.
•Implicit Cursor.
Today’s Lecture Outcomes
•Explicit cursor.
•Explicit Cursor Attributes.
•Cursor for loop.
•Parameterized Cursor.
Explicit Cursor
SQL%ROWCOUNT Returns the number of records fetched from the active data It is set
to zero when the cursor isopened.
Explicit Cursor (Example)
DECLARE
Cursor Name_Emp Is select ename from emp;
BEGIN
FOR N IN Name_Emp LOOP
Dbms_output.put_line(‘Employee Fetched:‘||N.emp_name);
END LOOP;
END;
Example 3
DECLARE
v_name VARCHAR2 (30);
--Declare
Cursor Emp_Cursor(var_e_id VARCHAR2) IS SELECT first_name FROM EMPLOYEES
WHERE employee_id < var_e_id;
BEGIN
OPEN Emp_Cursor(105);
LOOP FETCH Emp_Cursor INTO v_name;
EXIT WHEN Emp_Cursor %NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_name );
END LOOP;
CLOSE Emp_Cursor;
END;
Thank You…