src-db/database/model/triggers/AT_COMMAND_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 756 ae11e4610537
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 AT_COMMAND_TRG">
adrian@94
     3
    <trigger name="AT_COMMAND_TRG" table="AT_COMMAND" fires="after" insert="true" update="true" delete="false" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
adrian@94
     8
adrian@94
     9
/*************************************************************************
adrian@94
    10
* The contents of this file are subject to the Openbravo  Public  License
adrian@94
    11
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    12
* Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    13
* file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    14
* the License at http://www.openbravo.com/legal/license.html
adrian@94
    15
* Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    17
* License for the specific  language  governing  rights  and  limitations
adrian@94
    18
* under the License.
adrian@94
    19
* The Original Code is Openbravo ERP.
adrian@94
    20
* The Initial Developer of the Original Code is Openbravo SL
adrian@94
    21
* All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    22
* All Rights Reserved.
adrian@94
    23
* Contributor(s):  ______________________________________.
adrian@94
    24
************************************************************************/
adrian@94
    25
    BEGIN
adrian@94
    26
    -- Insert AT_Command Trigger
adrian@94
    27
    --  for Translation
adrian@94
    28
    IF INSERTING
adrian@94
    29
    THEN
adrian@94
    30
    --  Create Translation Row
adrian@94
    31
  INSERT
adrian@94
    32
  INTO AT_Command_Trl
adrian@94
    33
    (
adrian@94
    34
      AT_Command_ID, AD_LANGUAGE, AD_Client_ID,
adrian@94
    35
      AD_Org_ID, IsActive, Created,
adrian@94
    36
      CreatedBy, Updated, UpdatedBy,
adrian@94
    37
      Name, Description, ArgHelp1,
adrian@94
    38
      ArgHelp2, ArgHelp3, IsTranslated
adrian@94
    39
    )
adrian@94
    40
  SELECT :NEW.AT_Command_ID,
adrian@94
    41
    AD_LANGUAGE, :NEW.AD_Client_ID, :NEW.AD_Org_ID,
adrian@94
    42
    :NEW.IsActive, :NEW.Created, :NEW.CreatedBy,
adrian@94
    43
    :NEW.Updated, :NEW.UpdatedBy, :NEW.Name,
adrian@94
    44
    :NEW.Description, :NEW.ArgHelp1, :NEW.ArgHelp2,
adrian@94
    45
    :NEW.ArgHelp3,  'N'
adrian@94
    46
  FROM AD_LANGUAGE
adrian@94
    47
  WHERE IsActive='Y'
adrian@94
    48
    AND IsSystemLanguage='Y';
adrian@94
    49
 END IF;
adrian@94
    50
 -- Inserting
adrian@94
    51
 -- AT_Command update trigger
adrian@94
    52
 --  synchronize name,...
adrian@94
    53
 IF UPDATING THEN
gorkaion@239
    54
  IF(COALESCE(:old.Name, '.') <> COALESCE(:NEW.Name, '.')
gorkaion@239
    55
  OR COALESCE(:old.Description, '.') <> COALESCE(:NEW.Description, '.')
gorkaion@239
    56
  OR COALESCE(:old.ArgHelp1, 0) <> COALESCE(:NEW.ArgHelp1, 0)
gorkaion@239
    57
  OR COALESCE(:old.ArgHelp2, 0) <> COALESCE(:NEW.ArgHelp2, 0)
gorkaion@239
    58
  OR COALESCE(:old.ArgHelp3, 0) <> COALESCE(:NEW.ArgHelp3, 0))
adrian@94
    59
 THEN
adrian@94
    60
    UPDATE AT_Command_Trl
adrian@94
    61
      SET IsTranslated='N',
antonio@735
    62
      Updated=now()
adrian@94
    63
    WHERE AT_Command_ID=:NEW.AT_Command_ID;
adrian@94
    64
  END IF;
adrian@94
    65
 END IF;
adrian@94
    66
-- Updating
antonio@735
    67
END AT_COMMAND_TRG
gorkaion@239
    68
]]></body>
adrian@94
    69
    </trigger>
adrian@94
    70
  </database>