December 2010
Intermediate to advanced
451 pages
11h 16m
English
A query that you are issuing to the database will return many rows. You want to loop through those rows and process them accordingly.
There are a couple of different solutions for looping through rows from a query. One is to work directly with a SELECT statement and use a FOR loop along with it. In the following example, you will see this technique in action:
SET SERVEROUTPUT ON;
BEGIN
FOR emp IN
(
SELECT first_name, last_name, email
FROM employees
WHERE commission_pct is not NULL
)
LOOP
DBMS_OUTPUT.PUT_LINE(emp.first_name || ' ' || emp.last_name || ' - ' || emp.email);
END LOOP;
END;
Similarly, you can choose to use a FOR loop along with a cursor. ...
Read now
Unlock full access