src-db/database/model/triggers/M_PRODUCTIONPLAN_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 781 d68cf344696f
child 1605 8a0fe0193bef
permissions -rw-r--r--
Fix last update of copyright years in database files
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER M_PRODUCTIONPLAN_TRG">
adrian@94
     3
    <trigger name="M_PRODUCTIONPLAN_TRG" table="M_PRODUCTIONPLAN" fires="after" insert="true" update="true" delete="true" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
juanpablo@771
     5
    /*************************************************************************
juanpablo@771
     6
    * The contents of this file are subject to the Compiere Public
juanpablo@771
     7
    * License 1.1 ("License"); You may not use this file except in
juanpablo@771
     8
    * compliance with the License. You may obtain a copy of the License in
juanpablo@771
     9
    * the legal folder of your Openbravo installation.
adrian@94
    10
    * Software distributed under the License is distributed on an
adrian@94
    11
    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
adrian@94
    12
    * implied. See the License for the specific language governing rights
adrian@94
    13
    * and limitations under the License.
juanpablo@778
    14
    * The Original Code is  Compiere  ERP &  Business Solution
juanpablo@771
    15
    * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
adrian@94
    16
    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
adrian@94
    17
    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
adrian@94
    18
    * All Rights Reserved.
adrian@94
    19
    * Contributor(s): Openbravo SL
juanpablo@785
    20
    * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
juanpablo@771
    21
    *
juanpablo@771
    22
    * Specifically, this derivative work is based upon the following Compiere
juanpablo@771
    23
    * file and version.
adrian@94
    24
    *************************************************************************
adrian@94
    25
    * $Id: M_ProductionPlan_Trg.sql,v 1.2 2002/05/23 17:31:12 jjanke Exp $
adrian@94
    26
    ***
adrian@94
    27
    * Title: ReadOnly Check
adrian@94
    28
    * Description:
adrian@94
    29
    ************************************************************************/
adrian@94
    30
    v_ID NUMBER;
adrian@94
    31
  v_RO NUMBER;
adrian@94
    32
BEGIN
adrian@94
    33
  -- Get ID
adrian@94
    34
  IF(UPDATING OR INSERTING) THEN
adrian@94
    35
    v_ID:=:new.M_Production_ID;
adrian@94
    36
  ELSE
adrian@94
    37
    v_ID:=:old.M_Production_ID;
adrian@94
    38
  END IF;
adrian@94
    39
  -- ReadOnly Check
adrian@94
    40
  SELECT COUNT(*)
adrian@94
    41
  INTO v_RO
adrian@94
    42
  FROM M_Production
adrian@94
    43
  WHERE M_Production_ID=v_ID
adrian@94
    44
    AND(Processed='Y'
adrian@94
    45
    OR Posted='Y') ;
gorkaion@239
    46
  IF (v_RO > 0) THEN
adrian@94
    47
    IF (DELETING) THEN
adrian@94
    48
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    49
    END IF;
adrian@94
    50
    IF (UPDATING) THEN
gorkaion@239
    51
      IF (:new.M_PRODUCT_ID <> :old.M_PRODUCT_ID
gorkaion@239
    52
         OR :new.PRODUCTIONQTY <> :old.PRODUCTIONQTY
gorkaion@239
    53
         OR :new.M_LOCATOR_ID <> :old.M_LOCATOR_ID
gorkaion@239
    54
         OR :new.CONVERSIONRATE <> :old.CONVERSIONRATE
gorkaion@239
    55
         OR :new.MA_COSTCENTERUSE <> :old.MA_COSTCENTERUSE
gorkaion@239
    56
         OR :new.MA_WRPHASE_ID <> :old.MA_WRPHASE_ID
gorkaion@239
    57
         OR :new.NEEDEDQUANTITY <> :old.NEEDEDQUANTITY
gorkaion@239
    58
         OR :new.REJECTEDQUANTITY <> :old.REJECTEDQUANTITY
gorkaion@239
    59
         OR :new.SECONDARYQTY <> :old.SECONDARYQTY
gorkaion@239
    60
        OR :new.SECONDARYUNIT <> :old.SECONDARYUNIT
adrian@94
    61
        ) THEN
adrian@94
    62
        RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    63
      END IF;
adrian@94
    64
    END IF;
adrian@94
    65
  END IF;
antonio@735
    66
END M_PRODUCTIONPLAN_TRG
gorkaion@239
    67
]]></body>
adrian@94
    68
    </trigger>
adrian@94
    69
  </database>