SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table a (a int, b int); insert into a values (1,2),(3,4); create table b (a int, b int, c int); insert into b values (1,2,10),(3,4,20); create function f(t text) returns setof json language plpgsql as $$ begin if t = 'a' then return query select (row_to_json(a.*)) from a; else return query select (row_to_json(b.*)) from b; end if; end ; $$; select * from f('a'); select * from f('b');

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear