src-db/database/model/triggers/C_CURRENCY_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 799 fef2c5e2feb7
child 2078 cf88ca44cdd2
permissions -rw-r--r--
Merge r2.5x intro trunk
gorka@367
     1
<?xml version="1.0"?>
gorka@367
     2
  <database name="TRIGGER C_CURRENCY_TRG">
gorka@367
     3
    <trigger name="C_CURRENCY_TRG" table="C_CURRENCY" fires="after" insert="true" update="true" delete="false" foreach="row">
gorka@367
     4
      <body><![CDATA[
asier@799
     5
/*************************************************************************
asier@799
     6
* The contents of this file are subject to the Openbravo  Public  License
asier@799
     7
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
asier@799
     8
* Version 1.1  with a permitted attribution clause; you may not  use this
asier@799
     9
* file except in compliance with the License. You  may  obtain  a copy of
asier@799
    10
* the License at http://www.openbravo.com/legal/license.html
asier@799
    11
* Software distributed under the License  is  distributed  on  an "AS IS"
asier@799
    12
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@799
    13
* License for the specific  language  governing  rights  and  limitations
asier@799
    14
* under the License.
asier@799
    15
* The Original Code is Openbravo ERP.
asier@799
    16
* The Initial Developer of the Original Code is Openbravo SL
asier@799
    17
* All portions are Copyright (C) 2001-2008 Openbravo SL
asier@799
    18
* All Rights Reserved.
asier@799
    19
* Contributor(s):  ______________________________________.
asier@799
    20
************************************************************************/
asier@799
    21
gorka@367
    22
    BEGIN  IF INSERTING
gorka@367
    23
    THEN
gorka@367
    24
    --  Create Translation Row
gorka@367
    25
  INSERT
gorka@367
    26
  INTO C_CURRENCY_Trl
gorka@367
    27
    (
juanpablo@1605
    28
      C_CURRENCY_Trl_ID, C_CURRENCY_ID, AD_Language, AD_Client_ID,
gorka@367
    29
      AD_Org_ID, IsActive, Created,
gorka@367
    30
      CreatedBy, Updated, UpdatedBy,
gorka@367
    31
      IsTranslated, CurSymbol, Description
gorka@367
    32
    )
juanpablo@1605
    33
  SELECT get_uuid(), :new.C_CURRENCY_ID,
gorka@367
    34
    AD_Language, :new.AD_Client_ID, :new.AD_Org_ID,
gorka@367
    35
    :new.IsActive, :new.Created, :new.CreatedBy,
antonio@737
    36
    :new.Updated, :new.UpdatedBy,
gorka@370
    37
    'N', :new.CurSymbol, :new.Description
gorka@367
    38
  FROM AD_Language
gorka@367
    39
  WHERE IsActive='Y'
gorka@367
    40
    AND IsSystemLanguage='Y';
gorka@367
    41
 END IF;
gorka@367
    42
 -- Inserting
gorka@367
    43
 IF UPDATING THEN
gorka@367
    44
  IF(COALESCE(:old.CurSymbol, '.') <> COALESCE(:NEW.CurSymbol, '.')
gorka@367
    45
  OR COALESCE(:old.Description, '.') <> COALESCE(:NEW.Description, '.'))
gorka@367
    46
 THEN
gorka@367
    47
    -- Translation
gorka@367
    48
    UPDATE C_CURRENCY_Trl
gorka@367
    49
      SET IsTranslated='N',
antonio@735
    50
      Updated=now()
gorka@367
    51
    WHERE C_CURRENCY_ID=:new.C_CURRENCY_ID;
gorka@367
    52
  END IF;
gorka@367
    53
 END IF;
gorka@367
    54
-- Updating
antonio@735
    55
END C_CURRENCY_TRG
gorka@367
    56
]]></body>
gorka@367
    57
    </trigger>
gorka@367
    58
  </database>