Cursors
Cursor example
create function total_balances() returns numeric(10, 2) as $$
declare
account_cursor cursor for select * from account;
acct account;
total numeric(10, 2) = 0;
begin
for acct in account_cursor loop
total = total + acct.balance;
end loop;
return total;
end
$$ language plpgsql;
|