Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
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 AI support!

Copy Clear