src-db/database/model/triggers/MA_WRPHASE_TRG.xml
author rafaeldemiguel <rdm@openbravo.com>
Thu, 22 Sep 2011 18:28:46 +0200
changeset 14983 fcf3ccf492f3
parent 14979 da3863fa640f
child 25175 9e11efa4229f
permissions -rw-r--r--
[Production-Development] Triggers, DisplayLogics and ReadonlyLogics for windows WorkEffort and Production Run
rdm@14971
     1
<?xml version="1.0"?>
rdm@14971
     2
  <database name="TRIGGER MA_WRPHASE_TRG">
rdm@14971
     3
    <trigger name="MA_WRPHASE_TRG" table="MA_WRPHASE" fires="after" insert="true" update="true" delete="true" foreach="row">
rdm@14971
     4
      <body><![CDATA[
rdm@14971
     5
/*************************************************************************
rdm@14971
     6
* The contents of this file are subject to the Openbravo  Public  License
rdm@14971
     7
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
rdm@14971
     8
* Version 1.1  with a permitted attribution clause; you may not  use this
rdm@14971
     9
* file except in compliance with the License. You  may  obtain  a copy of
rdm@14971
    10
* the License at http://www.openbravo.com/legal/license.html
rdm@14971
    11
* Software distributed under the License  is  distributed  on  an "AS IS"
rdm@14971
    12
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
rdm@14971
    13
* License for the specific  language  governing  rights  and  limitations
rdm@14971
    14
* under the License.
rdm@14971
    15
* The Original Code is Openbravo ERP.
rdm@14971
    16
* The Initial Developer of the Original Code is Openbravo SLU
rdm@14979
    17
* All portions are Copyright (C) 2011 Openbravo SLU
rdm@14971
    18
* All Rights Reserved.
rdm@14971
    19
* Contributor(s):  ______________________________________.
rdm@14971
    20
************************************************************************/
rdm@14971
    21
rdm@14971
    22
    
rdm@14971
    23
BEGIN
rdm@14971
    24
    
rdm@14971
    25
    IF AD_isTriggerEnabled()='N' THEN RETURN;
rdm@14971
    26
    END IF;
rdm@14971
    27
rdm@14971
    28
IF (INSERTING) THEN
rdm@14971
    29
	UPDATE MA_WORKREQUIREMENT 
rdm@14983
    30
	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME
rdm@14971
    31
	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
rdm@14971
    32
END IF;
rdm@14971
    33
rdm@14971
    34
IF (UPDATING) THEN
rdm@14971
    35
	UPDATE MA_WORKREQUIREMENT 
rdm@14983
    36
	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME - :OLD.RUNTIME
rdm@14971
    37
	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
rdm@14971
    38
END IF;
rdm@14971
    39
rdm@14971
    40
IF (DELETING) THEN
rdm@14971
    41
	UPDATE MA_WORKREQUIREMENT 
rdm@14983
    42
	SET ESTIMATEDTIME = ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME - :OLD.RUNTIME
rdm@14971
    43
	WHERE MA_WORKREQUIREMENT_ID = :OLD.MA_WORKREQUIREMENT_ID;
rdm@14971
    44
END IF;
rdm@14971
    45
rdm@14971
    46
END MA_WRPHASE_TRG
rdm@14971
    47
]]></body>
rdm@14971
    48
    </trigger>
rdm@14971
    49
  </database>