// ****************************************************
// Disable all foreign key constraint before proceeding
LinkedList oConstraints = listConstraints(jCon2);
ListIterator oIter;
Constraint oCons;
String sSQL = null;
try {
oStmt = oConn.createStatement();
oIter = oConstraints.listIterator();
while (oIter.hasNext()) {
oCons = (Constraint) oIter.next();
switch (iDbms) {
case DBMS_MSSQL:
sSQL = "ALTER TABLE " + oCons.tablename + " NOCHECK CONSTRAINT " + oCons.constraintname;
break;
case DBMS_POSTGRESQL:
sSQL = "UPDATE pg_class SET reltriggers=0 WHERE relname = '" + oCons.tablename + "'";
break;
case DBMS_ORACLE:
sSQL = "ALTER TABLE " + oCons.tablename + " DISABLE CONSTRAINT " + oCons.constraintname;
break;
}
if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
oStmt.execute(sSQL);
} // wend
oStmt.close();
sSQL = null;
}
catch (SQLException sqle) {
DebugFile.writeln("SQLException: " + sqle.getMessage() + " " + sSQL + "\n");
iErrors++;
if (null!=oStrLog) oStrLog.append("SQLException: " + sqle.getMessage() + " " + sSQL + "\n");
}
// ********************************************
// Copy data from 1.x version datamodel to v2.0
com.knowgate.datacopy.CopyRegisters oCopy = new com.knowgate.datacopy.CopyRegisters(oProps.getProperty("schema1"), jCon1.getCatalog());
for (int t=0; t<iTables; t++) {
try {
if (DBMS_ORACLE==iDbms) sTables[t] = sTables[t].toUpperCase();
int iAppended = oCopy.append (jCon1, jCon2, sTables[t], sTables[t], null);
if (null!=oStrLog) oStrLog.append(String.valueOf(iAppended) + " registers appended or updated at table " + sTables[t] + "\n");
}
catch (SQLException sqle) {
DebugFile.writeln("SQLException: CopyRegisters.append(" + sTables[t] + ") " + sqle.getMessage() + "\n");
DebugFile.decIdent();
iErrors++;
if (null!=oStrLog) oStrLog.append("SQLException: CopyRegisters.append(" + sTables[t] + ") " + sqle.getMessage() + " " + "\n");
}
} // next (t)
// ************************************
// Additional tables witout primary key
PreparedStatement oWrtStm;
Statement oReadStm;
ResultSet oReadSet;
oWrtStm = jCon2.prepareStatement("INSERT INTO k_cat_expand (gu_rootcat,gu_category,od_level,od_walk,gu_parent_cat) VALUES (?,?,?,?,?)");
oReadStm = jCon1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
oReadSet = oReadStm.executeQuery("SELECT gu_rootcat,gu_category,od_level,od_walk,gu_parent_cat FROM k_cat_expand");
while (oReadSet.next()) {
oWrtStm.setObject(1, oReadSet.getObject(1));
oWrtStm.setObject(2, oReadSet.getObject(2));
oWrtStm.setObject(3, oReadSet.getObject(3));
oWrtStm.setObject(4, oReadSet.getObject(4));
oWrtStm.setObject(5, oReadSet.getObject(5));
oWrtStm.executeUpdate();
} // wend
oReadSet.close();
oReadStm.close();
oWrtStm.close();
oWrtStm = jCon2.prepareStatement("INSERT INTO k_project_expand (gu_rootprj,gu_project,nm_project,od_level,od_walk,gu_parent) VALUES (?,?,?,?,?,?)");
oReadStm = jCon1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
oReadSet = oReadStm.executeQuery("SELECT gu_rootprj,gu_project,nm_project,od_level,od_walk,gu_parent FROM k_project_expand");
while (oReadSet.next()) {
oWrtStm.setObject(1, oReadSet.getObject(1));
oWrtStm.setObject(2, oReadSet.getObject(2));
oWrtStm.setObject(3, oReadSet.getObject(3));
oWrtStm.setObject(4, oReadSet.getObject(4));
oWrtStm.setObject(5, oReadSet.getObject(5));
oWrtStm.setObject(6, oReadSet.getObject(6));
oWrtStm.executeUpdate();
} // wend
oReadSet.close();
oReadStm.close();
oWrtStm.close();
oWrtStm = jCon2.prepareStatement("INSERT INTO k_x_list_members (gu_list,tx_email,tx_name,tx_surname,tx_salutation,bo_active,dt_created,tp_member,gu_company,gu_contact,id_format,dt_modified) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
oReadStm = jCon1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
oReadSet = oReadStm.executeQuery("SELECT gu_list,tx_email,tx_name,tx_surname,tx_salutation,bo_active,dt_created,tp_member,gu_company,gu_contact,id_format,dt_modified FROM k_x_list_members");
while (oReadSet.next()) {
oWrtStm.setObject(1, oReadSet.getObject(1));
oWrtStm.setObject(2, oReadSet.getObject(2));
oWrtStm.setObject(3, oReadSet.getObject(3));
oWrtStm.setObject(4, oReadSet.getObject(4));
oWrtStm.setObject(5, oReadSet.getObject(5));
oWrtStm.setObject(6, oReadSet.getObject(6));
oWrtStm.setObject(7, oReadSet.getObject(7));
oWrtStm.setObject(8, oReadSet.getObject(8));
oWrtStm.setObject(9, oReadSet.getObject(9));
oWrtStm.setObject(10, oReadSet.getObject(10));
oWrtStm.setObject(11, oReadSet.getObject(11));
oWrtStm.setObject(12, oReadSet.getObject(12));
oWrtStm.executeUpdate();
} // wend
oReadSet.close();
oReadStm.close();
oWrtStm.close();
// **************************************************
// Enable all foreign key constraint after processing
try {
oStmt = oConn.createStatement();
oIter = oConstraints.listIterator();
while (oIter.hasNext()) {
oCons = (Constraint) oIter.next();
switch (iDbms) {
case DBMS_MSSQL:
sSQL = "ALTER TABLE " + oCons.tablename + " CHECK CONSTRAINT " + oCons.constraintname;
break;