Subject | Re: [firebird-support] Updating uncle and cousin tables in a trigger using UPDATE |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2003-07-17T08:07:46Z |
Raymond,
in general I think updating of other tables ought to be done in AFTER
INSERT/UPDATE triggers, not BEFORE INSERT/UPDATE, but if you ask me why, I
have no idea. As an alternative to your FOR SELECT, you could use
UPDATE "Description" D
SET D."Total" = D."Total" + NEW."Quantity"
WHERE EXISTS (
SELECT * FROM "Inventory Location" IL
WHERE D.ID = IL."Description ID"
AND IL.ID = NEW."Inventory Location ID")
This should work, but will (probably) be slower than your FOR SELECT if
your "Description" table contains lots of records.
Set
At 16:40 17.07.2003 +0930, you wrote:
in general I think updating of other tables ought to be done in AFTER
INSERT/UPDATE triggers, not BEFORE INSERT/UPDATE, but if you ask me why, I
have no idea. As an alternative to your FOR SELECT, you could use
UPDATE "Description" D
SET D."Total" = D."Total" + NEW."Quantity"
WHERE EXISTS (
SELECT * FROM "Inventory Location" IL
WHERE D.ID = IL."Description ID"
AND IL.ID = NEW."Inventory Location ID")
This should work, but will (probably) be slower than your FOR SELECT if
your "Description" table contains lots of records.
Set
At 16:40 17.07.2003 +0930, you wrote:
>This is what I want to do that isn't in the language:
>
>CREATE TRIGGER BI_UpdateDescAdjTotal
> FOR "Adjustment"
>AS
>BEGIN
> UPDATE "Description" D JOIN "Inventory Location" IL
> ON D.ID = IL."Description ID"
> SET D."Total" = D."Total" + NEW."Quantity"
> WHERE IL.ID = NEW."Inventory Location ID";
>END#