modules/org.openbravo.client.application/src-db/database/model/triggers/OBUIAPP_PARAMETER_MOD_TRG.xml
changeset 9076 c4f1a5c7d7c2
child 10780 bcc1e52f9ea9
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER OBUIAPP_PARAMETER_MOD_TRG">
       
     3     <trigger name="OBUIAPP_PARAMETER_MOD_TRG" table="OBUIAPP_PARAMETER" fires="before" insert="true" update="true" delete="true" foreach="row">
       
     4       <body><![CDATA[
       
     5 
       
     6 /*************************************************************************
       
     7 * The contents of this file are subject to the Openbravo  Public  License
       
     8 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
       
     9 * Version 1.1  with a permitted attribution clause; you may not  use this
       
    10 * file except in compliance with the License. You  may  obtain  a copy of
       
    11 * the License at http://www.openbravo.com/legal/license.html
       
    12 * Software distributed under the License  is  distributed  on  an "AS IS"
       
    13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
       
    14 * License for the specific  language  governing  rights  and  limitations
       
    15 * under the License.
       
    16 * The Original Code is Openbravo ERP.
       
    17 * The Initial Developer of the Original Code is Openbravo SLU
       
    18 * All portions are Copyright (C) 2010 Openbravo SLU
       
    19 * All Rights Reserved.
       
    20 * Contributor(s):  ______________________________________.
       
    21 ************************************************************************/
       
    22   devTemplate NUMBER;
       
    23   fieldCount NUMBER;
       
    24   selectorCount NUMBER;
       
    25   devModule   CHAR(1);
       
    26   currentModuleID  VARCHAR2(32);
       
    27   vAux NUMBER;
       
    28 
       
    29 BEGIN
       
    30     
       
    31     IF AD_isTriggerEnabled()='N' THEN RETURN;
       
    32     END IF;
       
    33 
       
    34     -- check that we can't change to a module not in development
       
    35     IF (UPDATING) THEN
       
    36         IF (COALESCE(:NEW.AD_Module_ID , '.') != COALESCE(:OLD.AD_Module_ID , '.')) THEN
       
    37             SELECT COUNT(*) 
       
    38                 INTO vAux
       
    39                 FROM AD_MODULE
       
    40                 WHERE AD_MODULE_ID = :old.AD_Module_ID
       
    41                 AND isindevelopment = 'N';
       
    42             IF (vAux!=0) THEN
       
    43                 RAISE_APPLICATION_ERROR(-20000, '@ChangeNotInDevModule@');
       
    44             END IF;
       
    45         END IF;
       
    46     END IF;
       
    47 
       
    48     SELECT COUNT(*)
       
    49         INTO devTemplate
       
    50         FROM AD_MODULE
       
    51         WHERE IsInDevelopment = 'Y'
       
    52         AND Type = 'T';
       
    53      
       
    54     IF (UPDATING OR INSERTING) THEN
       
    55         currentModuleID := :new.AD_Module_ID;
       
    56     ELSE
       
    57         currentModuleID := :old.AD_Module_ID;
       
    58     END IF;
       
    59 
       
    60     SELECT M.IsInDevelopment
       
    61         INTO devModule
       
    62         FROM AD_MODULE M
       
    63         WHERE M.AD_MODULE_ID = currentModuleID;
       
    64 
       
    65     IF (UPDATING AND devTemplate=0 AND devModule='N') THEN
       
    66         IF (
       
    67             COALESCE(:NEW.AD_Client_ID , '.') != COALESCE(:OLD.AD_Client_ID , '.') OR
       
    68             COALESCE(:NEW.AD_Org_ID , '.') != COALESCE(:OLD.AD_Org_ID , '.') OR
       
    69             COALESCE(:NEW.AD_Module_ID , '.') != COALESCE(:OLD.AD_Module_ID , '.') OR
       
    70             COALESCE(:NEW.IsActive , '.') != COALESCE(:OLD.IsActive , '.') OR
       
    71             COALESCE(:NEW.Name , '.') != COALESCE(:OLD.Name , '.') OR
       
    72             COALESCE(:NEW.Description , '.') != COALESCE(:OLD.Description , '.') OR
       
    73             COALESCE(:NEW.Help , '.') != COALESCE(:OLD.Help , '.') OR
       
    74             COALESCE(:NEW.seqno , 0) != COALESCE(:OLD.seqno , 0) OR
       
    75             COALESCE(:NEW.ad_reference_id , '.') != COALESCE(:OLD.ad_reference_id , '.') OR
       
    76             COALESCE(:NEW.ad_reference_value_id , '.') != COALESCE(:OLD.ad_reference_value_id , '.') OR
       
    77             COALESCE(:NEW.columnname , '.') != COALESCE(:OLD.columnname , '.') OR
       
    78             COALESCE(:NEW.iscentrallymaintained , '.') != COALESCE(:OLD.iscentrallymaintained , '.') OR
       
    79             COALESCE(:NEW.fieldlength , 0) != COALESCE(:OLD.fieldlength , 0) OR
       
    80             COALESCE(:NEW.ismandatory , '.') != COALESCE(:OLD.ismandatory , '.') OR
       
    81             COALESCE(:NEW.defaultvalue , '.') != COALESCE(:OLD.defaultvalue , '.') OR
       
    82             COALESCE(:NEW.ad_element_id , '.') != COALESCE(:OLD.ad_element_id , '.') OR
       
    83             COALESCE(:NEW.isfixed , '.') != COALESCE(:OLD.isfixed , '.') OR
       
    84             COALESCE(:NEW.fixedvalue , '.') != COALESCE(:OLD.fixedvalue , '.') OR
       
    85             COALESCE(:NEW.em_obkmo_widget_class_id , '.') != COALESCE(:OLD.em_obkmo_widget_class_id , '.') OR
       
    86             1=2) THEN
       
    87             RAISE_APPLICATION_ERROR(-20000, '@20532@');
       
    88         END IF;
       
    89     END IF;
       
    90 
       
    91 
       
    92     -- don't allow insert/delete if not in development
       
    93     IF ((DELETING OR INSERTING) AND devModule='N') THEN
       
    94         RAISE_APPLICATION_ERROR(-20000, '@20533@');
       
    95     END IF;
       
    96 END OBUIAPP_PARAMETER_MOD_TRG
       
    97 ]]></body>
       
    98     </trigger>
       
    99   </database>