SQL Task Example
Suppose the Travel Agency wishes to delete all Scheduled Tour records of tours that took place before 1996.
In this case, there is a relationship with a restricted delete rule between Scheduled Tours and Reservations. This means that the SQL task will first have to delete any Reservations for the Scheduled Tours that are to be deleted, and then the Scheduled Tours themselves.
The first SQL statement to be executed will therefore be as follows:
DELETE FROM reservation r
SELECT ' '
FROM schedtour st
WHERE st.schedtour_id = r.schedtour_id
AND st.return_date < '01-JAN-96'
and the second one will be:
DELETE FROM schedtour
WHERE return_date < '01-JAN-96'