modules/org.openbravo.client.querylist/src-db/database/model/triggers/OBCQL_QUERY_COLUMN_MOD_TRG.xml
changeset 9076 c4f1a5c7d7c2
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER OBCQL_QUERY_COLUMN_MOD_TRG">
       
     3     <trigger name="OBCQL_QUERY_COLUMN_MOD_TRG" table="OBCQL_QUERY_COLUMN" 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   currentwidgetqueryid  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     currentwidgetqueryid := :new.obcql_widget_query_id;
       
    38   ELSE
       
    39     currentwidgetqueryid := :old.obcql_widget_query_id;
       
    40   END IF;
       
    41 
       
    42   SELECT m.isindevelopment INTO devmodule
       
    43   FROM ad_module m, obkmo_widget_class wc, obcql_widget_query wq
       
    44   WHERE m.ad_module_id = wc.ad_module_id
       
    45     AND wq.obkmo_widget_class_id = wc.obkmo_widget_class_id
       
    46     AND wq.obcql_widget_query_id = currentwidgetqueryid;
       
    47 
       
    48   IF (UPDATING AND devtemplate=0 AND devmodule='N') THEN
       
    49     IF (
       
    50       COALESCE(:new.ad_client_id , '.') != COALESCE(:old.ad_client_id , '.') OR
       
    51       COALESCE(:new.ad_org_id , '.') != COALESCE(:old.ad_org_id , '.') OR
       
    52       COALESCE(:new.isactive , '.') != COALESCE(:old.isactive , '.') OR
       
    53       COALESCE(:new.obcql_widget_query_id, '.') != COALESCE(:old.obcql_widget_query_id , '.') OR
       
    54       COALESCE(:new.display_expression, '.') != COALESCE(:old.display_expression, '.') OR
       
    55       COALESCE(:new.name, '.') != COALESCE(:old.display_expression, '.') OR
       
    56       COALESCE(:new.summarize_type, '.') != COALESCE(:old.summarize_type, '.') OR
       
    57       COALESCE(:new.width, -1) != COALESCE(:old.width, -1) OR
       
    58       COALESCE(:new.link_expression, '.') != COALESCE(:old.link_expression, '.') OR
       
    59       COALESCE(:new.seqno, -1) != COALESCE(:old.seqno, -1) OR
       
    60       COALESCE(:new.ad_reference_id, '.') != COALESCE(:old.ad_reference_id, '.') OR
       
    61       COALESCE(:new.ad_reference_value_id, '.') != COALESCE(:old.ad_reference_value_id, '.') OR
       
    62       COALESCE(:new.include_in, '.') != COALESCE(:old.include_in, '.') OR
       
    63       1=2) THEN
       
    64       RAISE_APPLICATION_ERROR(-20000, '@20532@');
       
    65     END IF;
       
    66   END IF;
       
    67 
       
    68   -- don't allow insert/delete if not in development
       
    69   IF ((DELETING OR INSERTING) AND devmodule='N') THEN
       
    70     RAISE_APPLICATION_ERROR(-20000, '@20533@');
       
    71   END IF;
       
    72 END OBCQL_QUERY_COLUMN_MOD_TRG
       
    73 ]]></body>
       
    74     </trigger>
       
    75   </database>