Skip to content

For-each Loops

For-Each Loops

For-Each loops allow us to iterate over all results of a query.

Example

DECLARE n integer default 0;
FOR r AS
    SELECT budget
    FROM department
    WHERE dept_name = 'Music'
DO
    SET n = n + r.budget
END FOR