database - Execute postgres trigger after 24 hours after record insertion? -
i`m trying execute trigger after 24 hours after record insertion, each row, how this? please help
you know, if user doesn`t verificate email, account deleted.
without cron , on.
postgres db. postgresql
this may in relation scheduling sql command run @ time.
this command tested , use in pgagent.
delete email_tbl email_id in(select email_id email_tbl timestamp < now() - '1 day'::interval );
here test data used.
create extension citext; create domain email_addr citext check( value ~ '^[a-za-z0-9._%-]+@[a-za-z0-9.-]+[.][a-za-z]+$' ); create table email_tbl ( email_id serial primary key, email_addr email_addr not null unique, timestamp timestamp default current_timestamp );
and here's test data
insert email_tbl (email_addr) values('me@home.net') insert email_tbl (email_addr,timestamp) values('me2@home.net','2015-07-15 00:00:00'::timestamp) select * email_tbl timestamp < now() - '1 day'::interval
all best
Comments
Post a Comment