Owen Jacobson wrote:
> BEGIN;
> DELETE FROM note WHERE issue_id IN (SELECT issue_id FROM isuse
> WHERE reservation_id = reservation_to_delete);
> DELETE FROM isuse WHERE reservation_id = reservation_to_delete;
> DELETE FROM reservations WHERE reservation_id = reservation_to_delete;
> COMMIT;
>
> With an appropriate value or expression substituted into
> reservation_to_delete. This would be the "hard way", but (as it's in a
> single transaction) will still protect other clients from seeing a partial
> delete.
Yup, that's exactly how I delete reservations one a time. But here I
need to select a few thousand reservations, and I don't think this will
work:
BEGIN;
DELETE FROM note WHERE issue_id IN (SELECT issue_id FROM isuse
WHERE reservation_id IN
(select reservation_id from reservations where date > magic);
DELETE FROM isuse WHERE reservation_id IN
(select reservation_id from reservations where date > magic)
DELETE FROM reservations WHERE reservation_id IN
(select reservation_id from reservations where date > magic)
COMMIT;
I suppose I can do the subselect as a perl wrapper, but I was thinking
that maybe SQL could do it all for me....
-Bryce
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings