| | |
| | | values[0] = rs.getString("vptname"); |
| | | values[1] = rs.getShort("vptstatus"); |
| | | tmpTablenames.add(values); |
| | | if ((((Short) values[1]) & DataReposVersionManager.VSSTATUS_USING) != 0) { |
| | | if (((Short) values[1]) >= DataReposVersionManager.VSSTATUS_LINKVIEW) { |
| | | current = i; |
| | | } |
| | | i++; |
| | |
| | | Statement stmt = connection.createStatement(); |
| | | ResultSet rs = null; |
| | | try { |
| | | stmt.execute("CREATE TABLE " + tableName +" AS SELECT * FROM " + tempTable); |
| | | boolean found = false; |
| | | rs = connection.getMetaData().getTables(null, _pgSchema, tableName, new String[]{"TABLE"}); |
| | | if (rs.next()) { |
| | | stmt.execute("ALTER TABLE " + encodeSchemaTableName(_pgSchema, tableName) + |
| | | " ADD PRIMARY KEY (tid, oid)"); |
| | | found = true; |
| | | } |
| | | JDBCUtils.close(rs); |
| | | |
| | | if (!found) { |
| | | stmt.execute("CREATE TABLE " + tableName +" AS SELECT * FROM " + tempTable); |
| | | rs = connection.getMetaData().getTables(null, _pgSchema, tableName, new String[]{"TABLE"}); |
| | | if (rs.next()) { |
| | | stmt.execute("ALTER TABLE " + encodeSchemaTableName(_pgSchema, tableName) + |
| | | " ADD PRIMARY KEY (tid, oid)"); |
| | | } |
| | | } else { |
| | | stmt.execute("TRUNCATE "+ tableName + " CASCADE"); |
| | | stmt.execute("SELECT * INTO " + tableName + " FROM " + tempTable); |
| | | } |
| | | stmt.execute("DROP TABLE " + tempTable); |
| | | } finally { |