modules/org.openbravo.client.querylist/src-db/database/model/triggers/OBCQL_WIDGET_QUERY_MOD_TRG.xml
author Harpreet Singh <harpreet@openbravo.com>
Fri, 10 Dec 2010 19:47:45 +0100
changeset 9076 c4f1a5c7d7c2
permissions -rw-r--r--
Added 3.0 modules to modules dir and changed the VERSION number
harpreet@9076
     1
<?xml version="1.0"?>
harpreet@9076
     2
  <database name="TRIGGER OBCQL_WIDGET_QUERY_MOD_TRG">
harpreet@9076
     3
    <trigger name="OBCQL_WIDGET_QUERY_MOD_TRG" table="OBCQL_WIDGET_QUERY" fires="before" insert="true" update="true" delete="true" foreach="row">
harpreet@9076
     4
      <body><![CDATA[
harpreet@9076
     5
harpreet@9076
     6
/*************************************************************************
harpreet@9076
     7
* The contents of this file are subject to the Openbravo  Public  License
harpreet@9076
     8
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
harpreet@9076
     9
* Version 1.1  with a permitted attribution clause; you may not  use this
harpreet@9076
    10
* file except in compliance with the License. You  may  obtain  a copy of
harpreet@9076
    11
* the License at http://www.openbravo.com/legal/license.html
harpreet@9076
    12
* Software distributed under the License  is  distributed  on  an "AS IS"
harpreet@9076
    13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
harpreet@9076
    14
* License for the specific  language  governing  rights  and  limitations
harpreet@9076
    15
* under the License.
harpreet@9076
    16
* The Original Code is Openbravo ERP.
harpreet@9076
    17
* The Initial Developer of the Original Code is Openbravo SLU
harpreet@9076
    18
* All portions are Copyright (C) 2010 Openbravo SLU
harpreet@9076
    19
* All Rights Reserved.
harpreet@9076
    20
* Contributor(s):  ______________________________________.
harpreet@9076
    21
************************************************************************/
harpreet@9076
    22
  devtemplate NUMBER;
harpreet@9076
    23
  devmodule   CHAR(1);
harpreet@9076
    24
  currentwidgetclassid  VARCHAR2(32);
harpreet@9076
    25
harpreet@9076
    26
BEGIN
harpreet@9076
    27
  IF (AD_isTriggerEnabled()='N') THEN
harpreet@9076
    28
    RETURN;
harpreet@9076
    29
  END IF;
harpreet@9076
    30
harpreet@9076
    31
  SELECT COUNT(*) INTO devtemplate
harpreet@9076
    32
  FROM ad_module
harpreet@9076
    33
  WHERE isindevelopment = 'Y'
harpreet@9076
    34
  AND type = 'T';
harpreet@9076
    35
harpreet@9076
    36
  IF (UPDATING OR INSERTING) THEN
harpreet@9076
    37
    currentwidgetclassid := :new.obkmo_widget_class_id;
harpreet@9076
    38
  ELSE
harpreet@9076
    39
    currentwidgetclassid := :old.obkmo_widget_class_id;
harpreet@9076
    40
  END IF;
harpreet@9076
    41
harpreet@9076
    42
  SELECT m.isindevelopment INTO devmodule
harpreet@9076
    43
  FROM ad_module m, obkmo_widget_class wc
harpreet@9076
    44
  WHERE m.ad_module_id = wc.ad_module_id
harpreet@9076
    45
    AND wc.obkmo_widget_class_id = currentwidgetclassid;
harpreet@9076
    46
harpreet@9076
    47
  IF (UPDATING AND devtemplate=0 AND devmodule='N') THEN
harpreet@9076
    48
    IF (
harpreet@9076
    49
      COALESCE(:new.ad_client_id , '.') != COALESCE(:old.ad_client_id , '.') OR
harpreet@9076
    50
      COALESCE(:new.ad_org_id , '.') != COALESCE(:old.ad_org_id , '.') OR
harpreet@9076
    51
      COALESCE(:new.isactive , '.') != COALESCE(:old.isactive , '.') OR
harpreet@9076
    52
      COALESCE(:new.obkmo_widget_class_id , '.') != COALESCE(:old.obkmo_widget_class_id , '.') OR
harpreet@9076
    53
      COALESCE(:new.hql , '.') != COALESCE(:old.hql , '.') OR
harpreet@9076
    54
      1=2) THEN
harpreet@9076
    55
      RAISE_APPLICATION_ERROR(-20000, '@20532@');
harpreet@9076
    56
    END IF;
harpreet@9076
    57
  END IF;
harpreet@9076
    58
harpreet@9076
    59
harpreet@9076
    60
  -- don't allow insert/delete if not in development
harpreet@9076
    61
  IF ((DELETING OR INSERTING) AND devmodule='N') THEN
harpreet@9076
    62
    RAISE_APPLICATION_ERROR(-20000, '@20533@');
harpreet@9076
    63
  END IF;
harpreet@9076
    64
END OBCQL_WIDGET_QUERY_MOD_TRG
harpreet@9076
    65
]]></body>
harpreet@9076
    66
    </trigger>
harpreet@9076
    67
  </database>