foreach postgres
do
$$
declare
rec record;
begin
for rec in select title, length
from film
where length > 50
order by length
loop
raise notice '% (%)', rec.title, rec.length;
end loop;
end;
$$Code language: PostgreSQL SQL dialect and PL/pgSQL (pgsql)