Функция plpgsql с циклом по таблице
CREATE OR REPLACE FUNCTION public.test_table_iterator() RETURNS void AS $BODY$ DECLARE r record; BEGIN FOR r IN SELECT * FROM customers LOOP RAISE NOTICE 'name: % name: %', r.name, r.age; END LOOP; END; $BODY$ LANGUAGE plpgsql VOLATILE