Subject | Updating uncle and cousin tables in a trigger using UPDATE |
---|---|
Author | Raymond Kennington |
Post date | 2003-07-17T07:10:09Z |
I want to update a table that is pointed to by parent table.
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#
Is it necessary to use a FOR SELECT like:
FOR SELECT IL."Description ID"
FROM "Inventory Location" IL
WHERE IL.ID = NEW."Inventory Location ID"
INTO :DestinationID DO
BEGIN
UPDATE "Description" D
SET D."Total" = D."Total" + NEW."Quantity"
WHERE D.ID = :DestinationID;
END
This seems a bit much given that there is only one record to update.
Also, when the relationship is
great-great-great-grand-uncle-stepbrother or 4th cousins twice
removed, then this becomes much more cumbersome.
What is the easy way?
--
Raymond Kennington
Programming Solutions
TeamW2W (InfoPower)
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#
Is it necessary to use a FOR SELECT like:
FOR SELECT IL."Description ID"
FROM "Inventory Location" IL
WHERE IL.ID = NEW."Inventory Location ID"
INTO :DestinationID DO
BEGIN
UPDATE "Description" D
SET D."Total" = D."Total" + NEW."Quantity"
WHERE D.ID = :DestinationID;
END
This seems a bit much given that there is only one record to update.
Also, when the relationship is
great-great-great-grand-uncle-stepbrother or 4th cousins twice
removed, then this becomes much more cumbersome.
What is the easy way?
--
Raymond Kennington
Programming Solutions
TeamW2W (InfoPower)