database/model/triggers/M_INVENTORYLINE2_TRG.xml
author Adrián Romero <adrian.romero@openbravo.com>
Tue, 20 Nov 2007 16:27:14 +0000
changeset 94 4e7ba7b8a4ad
parent 59 85aab40b7d24
child 132 33c5ca45fcff
permissions -rw-r--r--
fix: Changed check constraint names and foreign key names to fit in to
30 characteres.
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER M_INVENTORYLINE2_TRG">
adrian@94
     3
    <trigger name="M_INVENTORYLINE2_TRG" table="M_INVENTORYLINE" fires="before" insert="true" update="true" delete="false" foreach="row">
adrian@94
     4
      <body>
adrian@94
     5
adrian@94
     6
adrian@94
     7
/*************************************************************************
adrian@94
     8
* The contents of this file are subject to the Openbravo  Public  License
adrian@94
     9
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    10
* Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    11
* file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    12
* the License at http://www.openbravo.com/legal/license.html
adrian@94
    13
* Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    14
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    15
* License for the specific  language  governing  rights  and  limitations
adrian@94
    16
* under the License.
adrian@94
    17
* The Original Code is Openbravo ERP.
adrian@94
    18
* The Initial Developer of the Original Code is Openbravo SL
adrian@94
    19
* All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    20
* All Rights Reserved.
adrian@94
    21
* Contributor(s):  ______________________________________.
adrian@94
    22
************************************************************************/
adrian@94
    23
    BEGIN IF(UPDATING)
adrian@94
    24
    THEN  IF NOT((COALESCE(:OLD.M_Product_Uom_ID, 0) &lt;&gt; COALESCE(:NEW.M_Product_Uom_ID, 0)
adrian@94
    25
    OR COALESCE(:OLD.QuantityOrderBook, 0) &lt;&gt; COALESCE(:NEW.QuantityOrderBook, 0)))
adrian@94
    26
    THEN  RETURN;
adrian@94
    27
    END IF;
adrian@94
    28
   END IF;
adrian@94
    29
 IF(UPDATING OR INSERTING) THEN
adrian@94
    30
  IF(:NEW.M_Product_Uom_ID IS NOT NULL AND :NEW.QuantityOrderBook IS NULL) THEN
adrian@94
    31
    :NEW.QuantityOrderBook:=0;
adrian@94
    32
  ELSIF(:NEW.M_Product_Uom_ID IS NULL AND :NEW.QuantityOrderBook IS NOT NULL) THEN
adrian@94
    33
    :NEW.QuantityOrderBook:=NULL;
adrian@94
    34
  END IF;
adrian@94
    35
 END IF;
adrian@94
    36
END M_InventoryLine2_Trg
adrian@94
    37
adrian@94
    38
</body>
adrian@94
    39
    </trigger>
adrian@94
    40
  </database>