How To Process Query Result in PL/SQL?
SQL tutorial | Interview questions | Oracle :: Interview questions :: Introduction to PL/SQL | Interview questions
Page 1 of 1
How To Process Query Result in PL/SQL?
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.
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.
Similar topics
» Operations on Result Sets in SQL
» What Is a SELECT Query Statement?
» How To Sort the Query Output?
» How To Name Query Output Columns?
» How To Divide Query Output into Groups?
» What Is a SELECT Query Statement?
» How To Sort the Query Output?
» How To Name Query Output Columns?
» How To Divide Query Output into Groups?
SQL tutorial | Interview questions | Oracle :: Interview questions :: Introduction to PL/SQL | Interview questions
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sun Jan 31, 2010 12:35 am by Micheal
» Accessing tables of other users in SQL
Sun Jan 31, 2010 12:34 am by Micheal
» Grouping commands in SQL
Sun Jan 31, 2010 12:32 am by Micheal
» Operations on Result Sets in SQL
Sun Jan 31, 2010 12:31 am by Micheal
» Subqueries in SQL
Sun Jan 31, 2010 12:30 am by Micheal
» Joining Relations in SQL
Sun Jan 31, 2010 12:28 am by Micheal
» Delete comand in SQL
Sun Jan 31, 2010 12:27 am by Micheal
» Update command in SQL
Sun Jan 31, 2010 12:26 am by Micheal
» Insert command in SQL
Sun Jan 31, 2010 12:23 am by Micheal