Subject | Re: [IBO] Calculating data |
---|---|
Author | |
Post date | 2014-09-08T14:03:59Z |
Hi Marcin, If I have 2 fields to update, is it better to have one larger Trigger or 2 smaller ones.
Secondly I have to update a single table field called "Quotahours". This field is the product of FTE2 * 690
Below is my code but is doesn't work.
SET TERM ^ ;
CREATE TRIGGER QUOTA FOR STAFF ACTIVE
AFTER INSERT OR UPDATE OR DELETE POSITION 1
AS
DECLARE VARIABLE STAFF_CODE INTEGER;
BEGIN
IF (INSERTING OR DELETING OR (UPDATING AND (NEW.QUOTAHOURS IS DISTINCT FROM OLD.QUOTAHOURS)))
THEN BEGIN
IF (DELETING)THEN STAFF_CODE = OLD.STAFF_CODE;
ELSE STAFF_CODE = NEW.STAFF_CODE;
UPDATE STAFF
SET QUOTAHOURS = (690 * FTE2)
WHERE STAFF_CODE = :STAFF_CODE;
END
END^
SET TERM ; ^
Can you see why my code doesn't work?
Terry