sqlpostgresqlfunction

How create many functions with one script in PGSQL


I want to ctreate many function at scheme with one sql script I'm trying the same:

begin

    create or replace function public.func1() returns text
    as $$ begin 
        return 'Test'
    end $$ language plpgsql;

    create or replace function public.func2() returns int
    as $$ begin 
        return 1
    end $$ language plpgsql;

commit;

but it creates only func1.

If you run the conditions for creating a function separately, then everything will work, but I don't want to create all the functions separately, I need one script that can be run and it will create several functions.

Postgres v13.3

To run scripts I use DBeaver.


Solution

  • DBeaver is the problem. I have seen numerous similar complaints here on SO.

    Add some missing semicolons and run the script in a less problematic client. Like psql or pgAdmin.

    fiddle