modules/org.openbravo.client.querylist/src-db/database/model/triggers/OBCQL_WIDGET_QUERY_MOD_TRG.xml
changeset 9076 c4f1a5c7d7c2
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER OBCQL_WIDGET_QUERY_MOD_TRG">
       
     3     <trigger name="OBCQL_WIDGET_QUERY_MOD_TRG" table="OBCQL_WIDGET_QUERY" 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   devmodule   CHAR(1);
       
    24   currentwidgetclassid  VARCHAR2(32);
       
    25 
       
    26 BEGIN
       
    27   IF (AD_isTriggerEnabled()='N') THEN
       
    28     RETURN;
       
    29   END IF;
       
    30 
       
    31   SELECT COUNT(*) INTO devtemplate
       
    32   FROM ad_module
       
    33   WHERE isindevelopment = 'Y'
       
    34   AND type = 'T';
       
    35 
       
    36   IF (UPDATING OR INSERTING) THEN
       
    37     currentwidgetclassid := :new.obkmo_widget_class_id;
       
    38   ELSE
       
    39     currentwidgetclassid := :old.obkmo_widget_class_id;
       
    40   END IF;
       
    41 
       
    42   SELECT m.isindevelopment INTO devmodule
       
    43   FROM ad_module m, obkmo_widget_class wc
       
    44   WHERE m.ad_module_id = wc.ad_module_id
       
    45     AND wc.obkmo_widget_class_id = currentwidgetclassid;
       
    46 
       
    47   IF (UPDATING AND devtemplate=0 AND devmodule='N') THEN
       
    48     IF (
       
    49       COALESCE(:new.ad_client_id , '.') != COALESCE(:old.ad_client_id , '.') OR
       
    50       COALESCE(:new.ad_org_id , '.') != COALESCE(:old.ad_org_id , '.') OR
       
    51       COALESCE(:new.isactive , '.') != COALESCE(:old.isactive , '.') OR
       
    52       COALESCE(:new.obkmo_widget_class_id , '.') != COALESCE(:old.obkmo_widget_class_id , '.') OR
       
    53       COALESCE(:new.hql , '.') != COALESCE(:old.hql , '.') OR
       
    54       1=2) THEN
       
    55       RAISE_APPLICATION_ERROR(-20000, '@20532@');
       
    56     END IF;
       
    57   END IF;
       
    58 
       
    59 
       
    60   -- don't allow insert/delete if not in development
       
    61   IF ((DELETING OR INSERTING) AND devmodule='N') THEN
       
    62     RAISE_APPLICATION_ERROR(-20000, '@20533@');
       
    63   END IF;
       
    64 END OBCQL_WIDGET_QUERY_MOD_TRG
       
    65 ]]></body>
       
    66     </trigger>
       
    67   </database>