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
DROP TABLE IF EXISTS employee; CREATE TABLE employee ( emp_name text, salary int, update_dt timestamp, update_usr_id text DEFAULT '0' ); insert into employee values ('Петр Болотин', 100000); create function c () returns trigger as $$ begin if NEW.emp_name is NULL or NEW.salary <= 0 then return NULL; end if; NEW.update_st = current_date; NEW.update_user_id = current_user; return NEW; end; $$ language plpqsql create trigger c_tr before insert of update on employee for each row execute function c; /*create function hello () returns text as $$ begin Return 'Hello'; end; $$ language plpgsql; select * from hello(); */ /*create function fact (a integer) returns integer as $$ declare factorial integer := 1; begin if a < 1 then return factorial; end if; for i in 1..a loop factorial = factorial * i; end loop; return facrorial; end; $$ language plpgsql; select * from fact(3); */ /*create funcrion r (str text) returns text as $$ begin Return reverse (str); end; $$ language plpgsql; select * from r(aba);*/ /*create function fact () returns date as $$ begin Return d + n days; end; $$ language plpgsql; select * from fact (30.11.2023);*/

Stuck with a problem? Got Error? Ask AI support!

Copy Clear