Postgresql stored procedure return select result set Postgresql stored procedure return select result set postgresql postgresql

Postgresql stored procedure return select result set


In Postgres a table automatically defines the corresponding type:

create or replace function select_my_table(argument1 int, argument2 int)returns setof my_table language sql as $$    select *    from my_table    where id > argument1 and id < argument2;$$;select * from select_my_table(0, 2);

The syntax is more verbose than in MS SQL Server because you can create functions in one of several languages and functions may be overloaded.