Tutorial by Examples

DECLARE CURSOR c_emp_to_be_raised(p_sal emp.sal%TYPE) IS SELECT * FROM emp WHERE sal < p_sal; BEGIN FOR cRowEmp IN c_emp_to_be_raised(1000) LOOP dbms_Output.Put_Line(cRowEmp .eName ||' ' ||cRowEmp.sal||'... should be raised ;)'); END LOOP; END; /
BEGIN FOR x IN (SELECT * FROM emp WHERE sal < 100) LOOP dbms_Output.Put_Line(x.eName ||' '||x.sal||'... should REALLY be raised :D'); END LOOP; END; / First advantage is there is no tedious declaration to do (think of this horrible "CURSOR" thing you had in previous ve...
SYS_REFCURSOR can be used as a return type when you need to easily handle a list returned not from a table, but more specifically from a function: function returning a cursor CREATE OR REPLACE FUNCTION list_of (required_type_in IN VARCHAR2) RETURN SYS_REFCURSOR IS v_ SYS_REFCURSOR; BEGIN...
Declare the cursor to scan a list of records Open it Fetch current record into variables (this increments position) Use %notfound to detect end of list Don't forget to close the cursor to limit resources consumption in current context -- DECLARE CURSOR curCols IS -- select column name a...

Page 1 of 1