Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save YPermitin/f47a2e9e29140c414919ccc51b54b36d to your computer and use it in GitHub Desktop.
Save YPermitin/f47a2e9e29140c414919ccc51b54b36d to your computer and use it in GitHub Desktop.
Пример курсора для PostgreSQL (plpgsql)
do $$
declare
text_result text default '';
rec_someval record;
dt_cursor cursor for
select
tablename AS table_name
from pg_catalog.pg_tables
order by tablename;
begin
open dt_cursor;
loop
fetch dt_cursor into rec_someval;
exit when not found;
text_result := text_result || chr(10) || rec_someval.table_name::text;
end loop;
close dt_cursor;
RAISE NOTICE '%', text_result;
end
$$ language 'plpgsql';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment