Jump to content

Delete orders


Recommended Posts

Hi,

I had the same question, and came up with the following if my order number is '1', and prefix 'ps2':
delete from ps2_orders where id_order=1;
delete from ps2_order_detail where id_order=1;
delete from ps2_order_return where id_order=1;
delete from ps2_order_slip where id_order=1;

As regards ps2_order_history, one could either delete the entries there two, or leave a trace by adding an entry with sate 999 (if we want to use that to mean deleted)
insert into ps2_order_history set id_order=1, id_order_state=999 date_add=now();

Is that enough, are other tables involved?

Hmm, we could also make a stored procedure, to have it available for the future:

DELIMITER //
CREATE PROCEDURE order_delete (i INT)
BEGIN
 delete from ps2_orders where id_order=i;
 delete from ps2_order_detail where id_order=i;
 delete from ps2_order_return where id_order=i;
 delete from ps2_order_slip where id_order=i;
 delete from ps2_order_history where id_order=i;
END //
DELIMITER ;



Then call it with order number as an argument:
call order_delete(1);

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...