From ca667b3dfa465e8fa65e27cd173fdebfabac08a0 Mon Sep 17 00:00:00 2001 From: esjmora Date: Thu, 14 Sep 2023 07:09:15 +0200 Subject: [PATCH] Fix bug #1317 --- .../provider/jdbctemplate/OracleServerTimeStatementsSource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/OracleServerTimeStatementsSource.java b/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/OracleServerTimeStatementsSource.java index a83843a33..4a8ac384d 100644 --- a/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/OracleServerTimeStatementsSource.java +++ b/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/OracleServerTimeStatementsSource.java @@ -32,7 +32,7 @@ class OracleServerTimeStatementsSource extends SqlStatementsSource { @Override String getInsertStatement() { - return "INSERT INTO " + tableName() + "(" + name() + ", " + lockUntil() + ", " + lockedAt() + ", " + lockedBy() + ") VALUES(:name, " + lockAtMostFor + ", " + now + ", :lockedBy)"; + return "MERGE INTO " + tableName() + " USING (SELECT 1 FROM dual) ON (" + name() + " = :name) WHEN MATCHED THEN UPDATE SET " + lockUntil() + " = " + lockAtMostFor + ", " + lockedAt() + " = " + now + ", " + lockedBy() + " = :lockedBy WHERE " + name() + " = :name AND " + lockUntil() + " <= " + now + " WHEN NOT MATCHED THEN INSERT(" + name() + ", " + lockUntil() + ", " + lockedAt() + ", " + lockedBy() + ") VALUES(:name, " + lockAtMostFor + ", " + now + ", :lockedBy)"; } @Override