SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How To Process Query Result in PL/SQL?

Go down

How To Process Query Result in PL/SQL? Empty How To Process Query Result in PL/SQL?

Post by Micheal Tue Jan 19, 2010 8:11 pm

You can run queries (SELECT statements) in a PL/SQL code blocks, and process the results a loop as shown in the following script example:
SQL> set serveroutput on;
SQL> BEGIN
2 FOR row IN
3 (SELECT * FROM employees WHERE manager_id = 101)
4 LOOP
5 DBMS_OUTPUT.PUT_LINE('Name = ' || row.last_name);
6 END LOOP;
7 END;
8 /
Name = Greenberg
Name = Whalen
Name = Mavris
Name = Baer
Name = Higgins
The loop statement in this script automatically sets a temporary variable "row" each row in the
result set returned from the SELECT statement.

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum