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 1AC1110A4C for ; Thu, 20 Feb 2014 20:56:25 +0000 (UTC) Received: (qmail 38439 invoked by uid 500); 20 Feb 2014 20:56:22 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 37881 invoked by uid 500); 20 Feb 2014 20:56:20 -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 37760 invoked by uid 99); 20 Feb 2014 20:56:19 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Feb 2014 20:56:19 +0000 Date: Thu, 20 Feb 2014 20:56:19 +0000 (UTC) From: "Rick Hillegas (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (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.atlassia= n.jira.plugin.system.issuetabpanels:all-tabpanel ] Rick Hillegas updated DERBY-3155: --------------------------------- Attachment: derby-3155-29-aa-missingSchema.diff Attaching derby-3155-29-aa-missingSchema.diff. This patch removes some obso= lete code which was causing us to see a missing schema error for the follow= ing case: {noformat} connect 'jdbc:derby:memory:db;user=3Dtest_dbo;create=3Dtrue'; call syscs_util.syscs_create_user( 'TEST_DBO', 'test_dbopassword' ); call syscs_util.syscs_create_user( 'RUTH', 'ruthpassword' ); connect 'jdbc:derby:memory:db;shutdown=3Dtrue'; connect 'jdbc:derby:memory:db;user=3Dtest_dbo;password=3Dtest_dbopassword' = as dbo; create table deleteTable_042 ( publicSelectColumn int ); create table selectTable_042 ( selectColumn int ); grant select on selectTable_042 to public; grant select on deleteTable_042 to public; grant delete on deleteTable_042 to ruth; connect 'jdbc:derby:memory:db;user=3Druth;password=3Druthpassword' as ruth; merge into test_dbo.deleteTable_042 using test_dbo.selectTable_042 on publicSelectColumn =3D selectColumn when matched then delete; {noformat} Touches the following files: M java/engine/org/apache/derby/impl/sql/compile/MergeNode.java M java/testing/org/apache/derbyTesting/functionTests/tests/lang/Merge= StatementTest.java > 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, MergeStatement.html, derby-3155-01-ac-grammar.diff, derby-3155-0= 2-ag-fixParserWarning.diff, derby-3155-03-ae-backingStoreHashtableWithRowLo= cation.diff, derby-3155-03-af-backingStoreHashtableWithRowLocation.diff, de= rby-3155-03-ag-backingStoreHashtableWithRowLocation.diff, derby-3155-03-ah-= backingStoreHashtableWithRowLocation.diff, derby-3155-04-ae-deleteAction.di= ff, derby-3155-04-af-deleteAction.diff, derby-3155-05-aa-triggerTransitionT= ableAsTarget.diff, derby-3155-06-aa-triggerTransitionTableAsSource.diff, de= rby-3155-07-ad-insertAction.diff, derby-3155-08-ah-updateAction.diff, derby= -3155-09-aa-correlationNames.diff, derby-3155-10-aa-correlationNames.diff, = derby-3155-11-ab-beforeTriggersCantFireMerge.diff, derby-3155-12-aa-canOmit= InsertColumnList.diff, derby-3155-13-aa-allowSystemAndTempTables.diff, derb= y-3155-14-aa-replaceCorrelationNamesOnLeftSideOfSETclauses.diff, derby-3155= -15-aa-replumbMergeResultSetCleanup.diff, derby-3155-16-aa-treatCurrentRowL= ocationNodeLikeBaseColumnNode.diff, derby-3155-17-aa-serializingRowLocation= s.diff, derby-3155-18-aa-basicView.diff, derby-3155-19-aa-forbidSubqueriesI= nMatchedClauses.diff, derby-3155-20-aa-reworkColumnMatching.diff, derby-315= 5-21-ac-cleanupAndForbidSynonyms.diff, derby-3155-22-ad-testIdentifiersOnLe= ftSideOfSetClauses.diff, derby-3155-23-aa-forbidDerivedColumnLists.diff, de= rby-3155-24-aa-supportParameters.diff, derby-3155-25-aa-parametersAsInsertV= alues.diff, derby-3155-26-aa-copyRowLocationForIndexScans.diff, derby-3155-= 27-aa-adjustMatchingRefinements.diff, derby-3155-28-aa-cardinalityViolation= s.diff, derby-3155-29-aa-missingSchema.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)