Subject Re: Delete with join and delete from multiple tables
Author Thomas
Hi Tim,

For the stored proc method you could play with something similar to:
CREATE PROCEDURE CLEAN_HISTORY
AS
DECLARE TT_ID INTEGER;
BEGIN
FOR
SELECT TT.ID
FROM T_TRANSACTIONS TT
INNER JOIN T_TRANSACTION_ROWS TR
ON TT.ITRANSACTION_ID = TR.ITRANSACTION_ID
INNER JOIN T_TRANSACTION_ROW_CONTENT TRC
ON TT.ITRANSACTION_ID = TRC.ITRANSACTION_ID
INNER JOIN T_UPLOADS TU
ON TT.ITRANSACTION_ID = TU.ITEM_ID
WHERE TT.TS < CURRENT_DATE - 60
AND TU.STATUS = 'INSYNC'
AND TU.ITEM_TYPE = 'TRANS'
INTO :TT_ID DO
BEGIN
DELETE FROM T_TRANSACTIONS
WHERE ID = :TT_ID;
END

SUSPEND;
END

Regards
Thomas Ellis