modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_BNKSTM_LINE_CHECK_TRG.xml
author Harpreet Singh <harpreet@openbravo.com>
Fri, 10 Dec 2010 19:47:45 +0100
changeset 9076 c4f1a5c7d7c2
child 21927 b4367a3c856c
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 APRM_FIN_BNKSTM_LINE_CHECK_TRG">
harpreet@9076
     3
    <trigger name="APRM_FIN_BNKSTM_LINE_CHECK_TRG" table="FIN_BANKSTATEMENTLINE" fires="before" insert="true" update="true" delete="true" foreach="row">
harpreet@9076
     4
      <body><![CDATA[
harpreet@9076
     5
harpreet@9076
     6
harpreet@9076
     7
/************************************************************************
harpreet@9076
     8
* The contents of this file are subject to the Openbravo  Public  License
harpreet@9076
     9
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
harpreet@9076
    10
* Version 1.1  with a permitted attribution clause; you may not  use this
harpreet@9076
    11
* file except in compliance with the License. You  may  obtain  a copy of
harpreet@9076
    12
* the License at http://www.openbravo.com/legal/license.html
harpreet@9076
    13
* Software distributed under the License  is  distributed  on  an "AS IS"
harpreet@9076
    14
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
harpreet@9076
    15
* License for the specific  language  governing  rights  and  limitations
harpreet@9076
    16
* under the License.
harpreet@9076
    17
* The Original Code is Openbravo ERP.
harpreet@9076
    18
* The Initial Developer of the Original Code is Openbravo SLU
harpreet@9076
    19
* All portions are Copyright (C) 2010 Openbravo SLU
harpreet@9076
    20
* All Rights Reserved.
harpreet@9076
    21
* Contributor(s):  ______________________________________.
harpreet@9076
    22
*************************************************************************/
harpreet@9076
    23
harpreet@9076
    24
v_Processed VARCHAR(60) ;
harpreet@9076
    25
v_Fin_Bankstatement_ID VARCHAR2(32) ;
harpreet@9076
    26
v_DateNull DATE := TO_DATE('01-01-1900','DD-MM-YYYY');
harpreet@9076
    27
    
harpreet@9076
    28
BEGIN
harpreet@9076
    29
    
harpreet@9076
    30
  IF AD_isTriggerEnabled()='N' THEN RETURN;
harpreet@9076
    31
  END IF;
harpreet@9076
    32
harpreet@9076
    33
  IF (INSERTING) THEN
harpreet@9076
    34
    v_Fin_Bankstatement_ID:=:NEW.Fin_Bankstatement_ID;
harpreet@9076
    35
  ELSE
harpreet@9076
    36
    v_Fin_Bankstatement_ID:=:OLD.Fin_Bankstatement_ID;
harpreet@9076
    37
  END IF;
harpreet@9076
    38
  
harpreet@9076
    39
  SELECT PROCESSED
harpreet@9076
    40
  INTO v_Processed
harpreet@9076
    41
  FROM Fin_Bankstatement
harpreet@9076
    42
  WHERE Fin_Bankstatement_ID=v_Fin_Bankstatement_ID;
harpreet@9076
    43
  
harpreet@9076
    44
  IF (UPDATING) THEN
harpreet@9076
    45
  	IF (v_Processed='Y') THEN
harpreet@9076
    46
    	    IF(((COALESCE(:OLD.AD_ORG_ID, '0') <> COALESCE(:NEW.AD_ORG_ID, '0'))
harpreet@9076
    47
      OR(COALESCE(:OLD.ISACTIVE, '0') <> COALESCE(:NEW.ISACTIVE, '0'))
harpreet@9076
    48
      OR(COALESCE(:OLD.FIN_BANKSTATEMENT_ID, '0') <> COALESCE(:NEW.FIN_BANKSTATEMENT_ID, '0'))
harpreet@9076
    49
      OR(COALESCE(:OLD.LINE, 0) <> COALESCE(:NEW.LINE, 0))
harpreet@9076
    50
      OR(COALESCE(:OLD.BPARTNERNAME, '0') <> COALESCE(:NEW.BPARTNERNAME, '0'))
harpreet@9076
    51
      OR(COALESCE(:OLD.DATETRX, v_DateNull) <> COALESCE(:NEW.DATETRX, v_DateNull))
harpreet@9076
    52
      OR(COALESCE(:OLD.CRAMOUNT, 0) <> COALESCE(:NEW.CRAMOUNT, 0))
harpreet@9076
    53
      OR(COALESCE(:OLD.DRAMOUNT, 0) <> COALESCE(:NEW.DRAMOUNT, 0))
harpreet@9076
    54
      OR(COALESCE(:OLD.REFERENCENO, '0') <> COALESCE(:NEW.REFERENCENO, '0'))
harpreet@9076
    55
      )) THEN
harpreet@9076
    56
      RAISE_APPLICATION_ERROR(-20000, '@20501@');
harpreet@9076
    57
    END IF;
harpreet@9076
    58
harpreet@9076
    59
  	END IF;
harpreet@9076
    60
  END IF;
harpreet@9076
    61
          
harpreet@9076
    62
  IF((DELETING OR INSERTING) AND v_Processed='Y') THEN
harpreet@9076
    63
	RAISE_APPLICATION_ERROR(-20000, '@20501@');
harpreet@9076
    64
  END IF;
harpreet@9076
    65
END APRM_FIN_BNKSTM_LINE_CHECK_TRG
harpreet@9076
    66
]]></body>
harpreet@9076
    67
    </trigger>
harpreet@9076
    68
  </database>