details:   /erp/erp/devel/main/rev/1cec102639e3
changeset: 4821:1cec102639e3
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Aug 27 12:59:12 2009 +0200
summary:   Fixed issue 10410. Upgrade to MP4 should now work.

diffstat:

 src-db/database/build.xml                  |  28 ++++++++++++++
 src-db/database/model/prescript-Oracle.sql |  40 +++++++++++++++----
 2 files changed, 59 insertions(+), 9 deletions(-)

diffs (102 lines):

diff -r c114070494f2 -r 1cec102639e3 src-db/database/build.xml
--- a/src-db/database/build.xml Wed Aug 26 15:41:16 2009 +0200
+++ b/src-db/database/build.xml Thu Aug 27 12:59:12 2009 +0200
@@ -121,7 +121,35 @@
     <antcall target="database.postupdate.${bbdd.rdbms}" />
   </target>
 
+  <target name="fix.date.ORACLE">
+    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" 
password="${bbdd.systemPassword}" onerror="continue">
+      <classpath>
+        <fileset dir="${base.lib}">
+          <include name="**/*.jar">
+          </include>
+        </fileset>
+      </classpath>
+      <transaction>
+        UPDATE ad_system_info SET last_dbupdate=last_dbupdate+1/24 
+      </transaction>
+    </sql>
+  </target>
+  <target name="fix.date.POSTGRE">
+    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" 
password="${bbdd.password}" onerror="continue" autocommit="true">
+          <classpath>
+            <fileset dir="${base.lib}">
+              <include name="**/*.jar">
+              </include>
+            </fileset>
+          </classpath>
+          <transaction>
+        </transaction>
+      </sql>
+    </target>
+  
+  
   <target name="update.database">
+    <antcall target="fix.date.${bbdd.rdbms}" />
     <alterdatabasedataall driver="${bbdd.driver}" url="${bbdd.owner.url}" 
user="${bbdd.user}" password="${bbdd.password}" 
excludeobjects="com.openbravo.db.OpenbravoExcludeFilter" model="model" 
filter="com.openbravo.db.OpenbravoMetadataFilter" input="sourcedata" 
object="${bbdd.object}" failonerror="false" verbosity="${bbdd.verbosity}" 
basedir="${base.modules}/" dirFilter="*/src-db/database/model" 
datadir="${base.modules}/" dataFilter="*/src-db/database/sourcedata" userId="0" 
propertiesFile="${base.config}/Openbravo.properties" force="${force}" 
onlyIfModified="${onlyIfModified}"/>
     <antcall target="database.postupdate.${bbdd.rdbms}" />
     <antcall target="update.dbupdate.timestamp" />
diff -r c114070494f2 -r 1cec102639e3 src-db/database/model/prescript-Oracle.sql
--- a/src-db/database/model/prescript-Oracle.sql        Wed Aug 26 15:41:16 
2009 +0200
+++ b/src-db/database/model/prescript-Oracle.sql        Thu Aug 27 12:59:12 
2009 +0200
@@ -84,7 +84,8 @@
 END GET_UUID;
 /-- END
 
-create or replace FUNCTION AD_DB_MODIFIED(p_Update CHAR) RETURN CHAR
+create or replace
+FUNCTION AD_DB_MODIFIED(p_Update CHAR) RETURN CHAR
 
 AS
 /*************************************************************************
@@ -103,20 +104,41 @@
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
+
+  v_md5 varchar(32);
+  aux varchar(32);
   v_Modified char(1);
+  TYPE RECORD IS REF CURSOR;
+  c1 RECORD;
   PRAGMA AUTONOMOUS_TRANSACTION; --To allow DML within a function in a select  
      
 BEGIN
-   SELECT (CASE WHEN COUNT(*)>0 THEN 'Y' ELSE 'N' END)
-    INTO v_Modified
-     FROM AD_SYSTEM_INFO
-     WHERE LAST_DBUPDATE < (SELECT MAX(LAST_DDL_TIME)
-                              FROM USER_OBJECTS);
-                              
-                     
+v_md5:='';
+for c1 in (select text from user_source order by name,line) loop
+     v_md5 := dbms_obfuscation_toolkit.md5(input_string => v_md5||c1.text);
+end loop;
+for c1 in (select * from user_tab_cols order by table_name, column_id) loop
+     v_md5 := dbms_obfuscation_toolkit.md5(input_string => 
v_md5||c1.column_name||c1.data_type||c1.data_length||c1.nullable);
+end loop;
+for c1 in (select * from user_views order by view_name) loop
+     v_md5 := dbms_obfuscation_toolkit.md5(input_string => 
v_md5||c1.view_name||c1.text);
+end loop;
+
+
+  select db_checksum
+    into aux
+    from ad_system_info;
+                                
+
+  if aux = v_md5 then
+    v_Modified := 'N';
+  else
+    v_Modified := 'Y';
+  end if;     
    BEGIN
    IF p_Update = 'Y' THEN
      UPDATE AD_SYSTEM_INFO
-       SET LAST_DBUPDATE = NOW();
+       SET LAST_DBUPDATE = NOW(),
+           DB_CHECKSUM = v_md5;
    END IF;
    END;
    COMMIT;

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to