SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
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 ChatGPT!
Copy Clear