How To Use an Explicit Cursor without OPEN Statements?
Submitted by: AdministratorIf you want to open a cursor and loop through its data rows in quick way, you can use the FOR ... IN ... LOOP statement in the same way as the implicit cursor. The following tutorial exercise gives you a good example:
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
CURSOR emp_cur IS SELECT * FROM employees
WHERE manager_id = 101;
BEGIN
FOR row IN emp_cur LOOP
DBMS_OUTPUT.PUT_LINE('Name = ' ||
row.first_name || ' ' || row.last_name);
END LOOP;
END;
/
Name = Nancy Greenberg
Name = Jennifer Whalen
Name = Susan Mavris
Name = Hermann Baer
Name = Shelley Higgins
Submitted by: Administrator
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
CURSOR emp_cur IS SELECT * FROM employees
WHERE manager_id = 101;
BEGIN
FOR row IN emp_cur LOOP
DBMS_OUTPUT.PUT_LINE('Name = ' ||
row.first_name || ' ' || row.last_name);
END LOOP;
END;
/
Name = Nancy Greenberg
Name = Jennifer Whalen
Name = Susan Mavris
Name = Hermann Baer
Name = Shelley Higgins
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Shutdown Your 10g XE Server? |
☺ | How To Write Date and Time Interval Literals in Oracle? |
☺ | How To Recover a Dropped Table in Oracle? |
☺ | What Happens to Indexes If You Drop a Table? |
☺ | How To Use "OUT" Parameter Properly? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |