How To Loop through Data Rows in the Implicit Cursor?
Submitted by: AdministratorYou use the FOR ... IN ... LOOP statement to loop through data rows in the implicit cursor as the following syntax:
FOR row IN dml_statement LOOP
(statement block with row.field)
END LOOP;
Here "row" is a local RECORD type variable with fields automatically defined to match the fields in the data rows resulted from the DML statement. Here is a good tutorial exercise on loop through data rows with the implicit cursor:
BEGIN
FOR row IN (SELECT * FROM employees
WHERE manager_id = 101) LOOP
DBMS_OUTPUT.PUT_LINE('Name = ' || row.last_name);
END LOOP;
END;
/
Name = Greenberg
Name = Whalen
Name = Mavris
Name = Baer
Name = Higgins
Submitted by: Administrator
FOR row IN dml_statement LOOP
(statement block with row.field)
END LOOP;
Here "row" is a local RECORD type variable with fields automatically defined to match the fields in the data rows resulted from the DML statement. Here is a good tutorial exercise on loop through data rows with the implicit cursor:
BEGIN
FOR row IN (SELECT * FROM employees
WHERE manager_id = 101) LOOP
DBMS_OUTPUT.PUT_LINE('Name = ' || row.last_name);
END LOOP;
END;
/
Name = Greenberg
Name = Whalen
Name = Mavris
Name = Baer
Name = Higgins
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How Oracle Handles Dead Locks? |
☺ | What Is the Relation of a User Account and a Schema? |
☺ | What Is Input Buffer in SQL*Plus? |
☺ | What Is the Oracle Implicit Cursor? |
☺ | What Happens to Indexes If You Drop a Table? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |