postgresql7.1
select r.reservation_id
from acs_events e join timespans s
on (e.timespan_id = s.timespan_id)
join time_intervals t
on (s.interval_id = t.interval_id)
join rr_reservations r
on (e.event_id = r.reservation_id)
where end_date < (current_timestamp - :expiry_days::INTERVAL);
select rr_reservations__delete(:reservation_id)