Skip to content

Commit

Permalink
Merge pull request #1528 from xmjosic/feature/1317
Browse files Browse the repository at this point in the history
Fix bug #1317
  • Loading branch information
lukas-krecan authored Sep 14, 2023
2 parents a140773 + ca667b3 commit e91ac0f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e91ac0f

Please sign in to comment.