diff --git a/src/fr/devinsy/sikevadb/SQLSikevaDB.java b/src/fr/devinsy/sikevadb/SQLSikevaDB.java index bf8dbb0..8180b64 100644 --- a/src/fr/devinsy/sikevadb/SQLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/SQLSikevaDB.java @@ -108,7 +108,8 @@ public class SQLSikevaDB implements SikevaDB { // connection = getConnection(); connection.setAutoCommit(true); - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL"); + statement = connection + .prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getArchiveDate())); statement.setString(2, element.getKey()); @@ -147,7 +148,7 @@ public class SQLSikevaDB implements SikevaDB { // connection = getConnection(); connection.setAutoCommit(true); - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?"); + statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=? AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getArchiveDate())); statement.setString(2, element.getKey()); @@ -1715,7 +1716,7 @@ public class SQLSikevaDB implements SikevaDB { connection.setAutoCommit(false); // Archive existing element. - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL"); + statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getEditionDate())); statement.setString(2, element.getKey()); @@ -1784,7 +1785,7 @@ public class SQLSikevaDB implements SikevaDB { connection.setAutoCommit(false); // Archive existing element. - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?"); + statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=? AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getEditionDate())); statement.setString(2, element.getKey());