archiving table records to another table by trigger(move daialy table records to weekly table, evry
Posted
by sirvan
on Stack Overflow
See other posts from Stack Overflow
or by sirvan
Published on 2010-05-26T06:34:25Z
Indexed on
2010/05/26
8:31 UTC
Read the original article
Hit count: 432
I have written this trigger in mysql 5:
create trigger changeToWeeklly after insert on tbl_daily for each row
begin
insert into tbl_weeklly SELECT * FROM vehicleslocation v
where v.recivedate < curdate();
delete FROM tbl_daily where recivedate < curdate();
end;
i want to archive records by date, move yesterday inserted record from dailly to weekly table and last weekly table to mounthly table and deletes this records from previous table this trigger has following error when insert in daily tabled occurred : "Can't update table 'tbl_daily' in stored function/trigger because it is already used by statement which invoked this stored function/trigger."
please help me to solve th problem of archive old data in related tables:
move yesterday inserted records to weekly table, if there is a reliable solution tell me please.
© Stack Overflow or respective owner