src-db/database/model/triggers/C_CONVERSION_RATE_TRG2.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 756 ae11e4610537
child 1815 90049ce97ab4
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 C_CONVERSION_RATE_TRG2">
adrian@94
     3
    <trigger name="C_CONVERSION_RATE_TRG2" table="C_CONVERSION_RATE" fires="after" insert="true" update="true" delete="false" foreach="statement">
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
************************************************************************/
antonio@735
    25
  v_Count NUMBER;
adrian@94
    26
   BEGIN
adrian@94
    27
     --check for repeated dates
adrian@94
    28
   select count(*)
adrian@94
    29
    into v_Count
adrian@94
    30
    from c_Conversion_Rate r1,
adrian@94
    31
         c_Conversion_Rate r2
adrian@94
    32
   where ((r1.VALIDFROM+1 between r2.ValidFrom and r2.ValidTo)
adrian@94
    33
        or (r1.VALIDTo-1 between r2.ValidFrom and r2.ValidTo))
adrian@94
    34
    and r1.C_CURRENCY_ID = r2.C_Currency_ID
adrian@94
    35
    and r1.C_Currency_ID_To = r2.C_Currency_ID_To
adrian@94
    36
    and r1.c_Conversion_Rate_ID != r2.c_Conversion_Rate_ID;
adrian@94
    37
gorkaion@239
    38
   if v_Count > 0 then
antonio@735
    39
     RAISE_APPLICATION_ERROR(-20504, 'There are different conversion rates with same dates');
adrian@94
    40
   end if;
adrian@94
    41
adrian@94
    42
adrian@94
    43
antonio@735
    44
END C_CONVERSION_RATE_TRG2
gorkaion@239
    45
]]></body>
adrian@94
    46
    </trigger>
adrian@94
    47
  </database>