src-db/database/model/triggers/MA_WRPHASE_TRG.xml
author rafaeldemiguel <rdm@openbravo.com>
Fri, 26 Aug 2011 12:16:48 +0200
changeset 14971 647881af7155
child 14979 da3863fa640f
permissions -rw-r--r--
[Production-Development] AD ProcessPlan WorkRequirement
<?xml version="1.0"?>
  <database name="TRIGGER MA_WRPHASE_TRG">
    <trigger name="MA_WRPHASE_TRG" table="MA_WRPHASE" fires="after" insert="true" update="true" delete="true" foreach="row">
      <body><![CDATA[
/*************************************************************************
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License  is  distributed  on  an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific  language  governing  rights  and  limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2001-2010 Openbravo SLU
* All Rights Reserved.
* Contributor(s):  ______________________________________.
************************************************************************/

    
BEGIN
    
    IF AD_isTriggerEnabled()='N' THEN RETURN;
    END IF;

IF (INSERTING) THEN
	UPDATE MA_WORKREQUIREMENT 
	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME
	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
END IF;

IF (UPDATING) THEN
	UPDATE MA_WORKREQUIREMENT 
	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME - :OLD.ESTIMATEDTIME
	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
END IF;

IF (DELETING) THEN
	UPDATE MA_WORKREQUIREMENT 
	SET ESTIMATEDTIME = ESTIMATEDTIME - :OLD.ESTIMATEDTIME
	WHERE MA_WORKREQUIREMENT_ID = :OLD.MA_WORKREQUIREMENT_ID;
END IF;

END MA_WRPHASE_TRG
]]></body>
    </trigger>
  </database>