Can i get rid of the while loop in the code below and make the delete faster?
I have an order header table (table1), where this order has 2 types of lines (tableline1 and tableline2)
so it's like salesTable and imagine there is salesLine1 table and SalesLine2 table both linked to header salesTable
and i want to delete all orders with their 2 table lines where the header has a specifIc value for InventLocationId
and of course i need to make sure i delete the lines tables first before the header
class DeleteOrderService extends SysOperationServiceBase
{
public void deleteOrder()
{
Table1 table1;
TableLine1 line1Delete;
TableLine2 line2Delete;
Table1 table1Delete;
while select Id from table1 where table1.InventLocationId == XParameters::find().LocationId
{
delete_from line1Delete where line1Delete.Id == table1.Id;
delete_from line2Delete where line2Delete.Id == table1.Id;
delete_from table1Delete where table1Delete.Id == table1.Id;
}
}
}
it's like i would like to delete everything that this query returns:
select TABLE1.ID,INVENTLOCATIONID,*from TABLE1
join TABLELINE1 on TABLELINE1.ID = TABLE1.ID
join TABLELINE2 on TABLELINE2.ID = TABLE1.ID
where INVENTLOCATIONID = 'XX'