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 units( first_name varchar(10) not null, period_of_storage timestamp not null, finish_date int ); create or replace function get_finish_date() returns trigger as $$ begin new.finish_date := extract(day from current_date) - extract(day from new.period_of_storage); return new; end; $$ language plpgsql; create trigger update_finish_date before insert on units for each row execute function get_finish_date(); insert into units (first_name,period_of_storage) values ('one', '2023-03-19'), ('two', '2023-03-20'), ('three', '2023-03-21'); select * from units

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

Copy Clear