details:   https://code.openbravo.com/erp/devel/pi/rev/391faee2dfa8
changeset: 17769:391faee2dfa8
user:      Javier Etxarri <javier.echarri <at> openbravo.com>
date:      Mon Aug 27 09:06:11 2012 +0200
summary:   Fixes issue 19405: Error when you try to change a period's name in 
Oracle

diffstat:

 src-db/database/model/triggers/C_PERIOD_TRG2.xml |  13 +-----
 src-db/database/model/triggers/C_PERIOD_TRG3.xml |  47 ++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 11 deletions(-)

diffs (76 lines):

diff -r f0e539b56601 -r 391faee2dfa8 
src-db/database/model/triggers/C_PERIOD_TRG2.xml
--- a/src-db/database/model/triggers/C_PERIOD_TRG2.xml  Fri Aug 24 09:38:57 
2012 +0200
+++ b/src-db/database/model/triggers/C_PERIOD_TRG2.xml  Mon Aug 27 09:06:11 
2012 +0200
@@ -52,19 +52,10 @@
        IF (INSERTING AND :NEW.PERIODTYPE = 'C_YEARPERIOD') THEN
                -- Creating periods from procedure, no need to check dates
                :NEW.PERIODTYPE := 'S';
-       ELSE
+       Else
                IF (:NEW.STARTDATE > :NEW.ENDDATE) THEN
                        RAISE_APPLICATION_ERROR(-20000, '@DatesWrong@');
-               END IF;
-               SELECT COUNT(*) INTO V_COUNT 
-               FROM C_PERIOD 
-               WHERE C_PERIOD_ID <> :NEW.C_PERIOD_ID 
-                       AND AD_ORG_ID = :NEW.AD_ORG_ID
-                       AND :NEW.STARTDATE <= ENDDATE 
-                       AND :NEW.ENDDATE >= STARTDATE;
-               IF (V_COUNT > 0) THEN
-                       RAISE_APPLICATION_ERROR(-20000, '@DatesOverlapped@');
-               END IF;
+               End If;
        END IF;
    END IF;
 
diff -r f0e539b56601 -r 391faee2dfa8 
src-db/database/model/triggers/C_PERIOD_TRG3.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/C_PERIOD_TRG3.xml  Mon Aug 27 09:06:11 
2012 +0200
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER C_PERIOD_TRG3">
+    <trigger name="C_PERIOD_TRG3" table="C_PERIOD" fires="after" insert="true" 
update="true" delete="false" foreach="statement">
+      <body><![CDATA[    
/*************************************************************************
+    * The contents of this file are subject to the Openbravo  Public  License
+    * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+    * Version 1.1  with a permitted attribution clause; you may not  use this
+    * file except in compliance with the License. You  may  obtain  a copy of
+    * the License at http://www.openbravo.com/legal/license.html
+    * Software distributed under the License  is  distributed  on  an "AS IS"
+    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+    * License for the specific  language  governing  rights  and  limitations
+    * under the License.
+    * The Original Code is Openbravo ERP.
+    * The Initial Developer of the Original Code is Openbravo SLU
+    * All portions are Copyright (C) 2012 Openbravo SLU
+    * All Rights Reserved.
+    * Contributor(s):  ______________________________________.
+    ************************************************************************/
+
+    V_Count NUMBER:= 0;
+    TYPE RECORD IS REF CURSOR;
+    Cur_Period RECORD;
+Begin
+    For Cur_Period In
+      (Select * 
+      From C_Period
+      Where C_Period_Id In (Select Distinct(Cp.C_Period_Id)
+      From C_Period Cp 
+            Join C_Periodcontrol Cpc On Cpc.C_Period_Id= Cp.C_Period_Id 
+      Where Periodstatus = 'O'))
+    Loop
+       Select Count(*) 
+       Into V_COUNT
+       From C_Period 
+       Where C_Period_Id <> Cur_Period.C_Period_Id
+       And Ad_Org_Id=Cur_Period.Ad_Org_Id
+       And Cur_Period.startdate <= Enddate
+                        And Cur_Period.Enddate >= Startdate;
+       If (V_COUNT > 0) Then
+         RAISE_APPLICATION_ERROR(-20000, '@DatesOverlapped@');
+       End if;
+    End Loop;
+END C_PERIOD_TRG3
+]]></body>
+    </trigger>
+  </database>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to