Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save YPermitin/f47a2e9e29140c414919ccc51b54b36d to your computer and use it in GitHub Desktop.

Select an option

Save YPermitin/f47a2e9e29140c414919ccc51b54b36d to your computer and use it in GitHub Desktop.

Revisions

  1. YPermitin created this gist Apr 3, 2022.
    23 changes: 23 additions & 0 deletions Пример курсора для PostgreSQL (plpgsql).sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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';