I need to have a routine/function/stored proc/whatever to archive particular accounts from our 'active' table, to an inactive table.
I can write this out as a group of queries, all executed in order by PHP one at a time, but I'm looking to offload most of the work to mysql because it's not necessary for PHP to be involved here.
Basically, this would get all the data:
insert into credit_archive_acc select * from credit_acc where uid_usr = n;
delete from credit_acc where uid_usr =n;
insert into user_archive_usr select * from user_usr where id_usr = n;
delete from user_usr where id_usr = n;
(about 3 other tables I'll do this to)
Anyway, I'd like to just be able to do something like: call archive_account(n); and have that do all the work (and as a transaction with rollback if it fails)
Am I asking too much of mysql?