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 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 AI support!

Copy Clear