SQLize Online / PHPize Online  /  SQLtest Online

Share      Blog   Popular
Copy Format Clear
create or replace function avc(val anyelement) returns boolean as $$ declare _jval jsonb; begin _jval := to_jsonb(val); if (_jval->>'is_active')::boolean = true then return true; end if; return false; end; $$ language plpgsql; with cte(is_active) as ((values (true ), (false ))) select avc(cte.*) from cte; drop table if exists t; create table t(id serial, is_active boolean); insert into t(is_active) values (true), (false), (true); select avc(t.*) from t;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear