You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by "Rainer Döbele (JIRA)" <em...@incubator.apache.org> on 2016/10/29 11:24:58 UTC

[jira] [Commented] (EMPIREDB-247) Add Support for "insertOrUpdate" ("UPSERT")

    [ https://issues.apache.org/jira/browse/EMPIREDB-247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15617969#comment-15617969 ] 

Rainer Döbele commented on EMPIREDB-247:
----------------------------------------

Can we close this issue?

> Add Support for "insertOrUpdate" ("UPSERT")
> -------------------------------------------
>
>                 Key: EMPIREDB-247
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-247
>             Project: Empire-DB
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: empire-db-2.4.4
>            Reporter: jan
>            Assignee: jan
>            Priority: Minor
>
> It should be possible to create a "insertOrUpdate" statement from a DBCommand and perform a "executeInsertOrUpdate" in DBDatabase.
> This feature requires database dependent implementations. 
> - for MySQL / MariaDB "INSERT ... ON DUPLICATE KEY UPDATE" (http://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html) can be used
> - for Oracle "MERGE INTO" can be used
> - for MSSQL merge should work, too
> - for Postgres "INSERT ... ON CONFLICT UPDATE" (https://wiki.postgresql.org/wiki/UPSERT) can be used
> DBDatabase.executeInsertOrUpdate could use something like
> int count = db.executeUpdate(cmd, conn);
> if (count < 1) {
> 	// nothing updated -> INSERT
> 	count += db.executeInsert(cmd, conn);
> }
> return count;
> as fallback. I dont think a fallback is possible in DBCommand, so the default implementation should throw a NotSupportedException.
> The DBDriverFeature should be extended by PERFORM_INSERT_OR_UPDATE or maybe PERFORM_UPSERT.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)