Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E9C13108FF for ; Fri, 7 Feb 2014 15:09:23 +0000 (UTC) Received: (qmail 55234 invoked by uid 500); 7 Feb 2014 15:09:23 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 55032 invoked by uid 500); 7 Feb 2014 15:09:23 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 54999 invoked by uid 99); 7 Feb 2014 15:09:22 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Feb 2014 15:09:22 +0000 Date: Fri, 7 Feb 2014 15:09:21 +0000 (UTC) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-3155) Support for SQL:2003 MERGE statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-3155?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1389= 4610#comment-13894610 ]=20 Knut Anders Hatlen commented on DERBY-3155: ------------------------------------------- Whoops... {noformat} ij> create view sr(i) as values 1; 0 rows inserted/updated/deleted ij> create table t(x int, y int, z int); 0 rows inserted/updated/deleted ij> create unique index idx on t(x, y); 0 rows inserted/updated/deleted ij> prepare ps as 'merge into t using sr on (x =3D ? and y =3D ?) when matc= hed then update set y =3D ?'; ERROR XSAI2: The conglomerate (0) requested does not exist. {noformat} > Support for SQL:2003 MERGE statement > ------------------------------------ > > Key: DERBY-3155 > URL: https://issues.apache.org/jira/browse/DERBY-3155 > Project: Derby > Issue Type: Improvement > Components: SQL > Reporter: Trejkaz > Assignee: Rick Hillegas > Labels: derby_triage10_10 > Attachments: MergeStatement.html, MergeStatement.html, MergeState= ment.html, derby-3155-01-ac-grammar.diff, derby-3155-02-ag-fixParserWarning= .diff, derby-3155-03-ae-backingStoreHashtableWithRowLocation.diff, derby-31= 55-03-af-backingStoreHashtableWithRowLocation.diff, derby-3155-03-ag-backin= gStoreHashtableWithRowLocation.diff, derby-3155-03-ah-backingStoreHashtable= WithRowLocation.diff, derby-3155-04-ae-deleteAction.diff, derby-3155-04-af-= deleteAction.diff, derby-3155-05-aa-triggerTransitionTableAsTarget.diff, de= rby-3155-06-aa-triggerTransitionTableAsSource.diff, derby-3155-07-ad-insert= Action.diff, derby-3155-08-ah-updateAction.diff, derby-3155-09-aa-correlati= onNames.diff, derby-3155-10-aa-correlationNames.diff, derby-3155-11-ab-befo= reTriggersCantFireMerge.diff, derby-3155-12-aa-canOmitInsertColumnList.diff= , derby-3155-13-aa-allowSystemAndTempTables.diff, derby-3155-14-aa-replaceC= orrelationNamesOnLeftSideOfSETclauses.diff, derby-3155-15-aa-replumbMergeRe= sultSetCleanup.diff, derby-3155-16-aa-treatCurrentRowLocationNodeLikeBaseCo= lumnNode.diff, derby-3155-17-aa-serializingRowLocations.diff, derby-3155-18= -aa-basicView.diff, derby-3155-19-aa-forbidSubqueriesInMatchedClauses.diff,= derby-3155-20-aa-reworkColumnMatching.diff > > > A relatively common piece of logic in a database application is to check = for a row's existence and then either update or insert depending on its exi= stence. > SQL:2003 added a MERGE statement to perform this operation. It looks lik= e this: > MERGE INTO table_name USING table_name ON (condition) > WHEN MATCHED THEN UPDATE SET column1 =3D value1 [, column2 =3D value2= ...] > WHEN NOT MATCHED THEN INSERT column1 [, column2 ...] VALUES (value1 [= , value2 ...])=20 > At the moment, the only workaround for this would be to write a stored pr= ocedure to do the same operation, or to implement the logic client-side. -- This message was sent by Atlassian JIRA (v6.1.5#6160)