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 750F611E70 for ; Sun, 31 Aug 2014 09:57:53 +0000 (UTC) Received: (qmail 69010 invoked by uid 500); 31 Aug 2014 09:57:53 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 68981 invoked by uid 500); 31 Aug 2014 09:57:53 -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 68772 invoked by uid 99); 31 Aug 2014 09:57:53 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 Aug 2014 09:57:53 +0000 Date: Sun, 31 Aug 2014 09:57:53 +0000 (UTC) From: "Aleksei Kovura (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DERBY-6723) Allow derived table as a source in MERGE statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-6723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Aleksei Kovura updated DERBY-6723: ---------------------------------- Description: I'm trying to utilize MERGE to do an upsert operation like this: MERGE INTO "APP"."ST_KEY_VAL" trg USING (SELECT * FROM (VALUES ('key1', 'val1')) as t1 (st_key, st_val)) as src ON trg.st_key = src.st_key WHEN MATCHED THEN UPDATE SET st_val = src.st_val WHEN NOT MATCHED THEN INSERT VALUES (src.st_key, src.st_val) ; Derby returns an error: Error: The source table of a MERGE statement must be a base table or table function. SQLState: 42XAL ErrorCode: 30000 MERGE is used this way on other databases, unfortunately I can't find whether it is standard compliant or not. If this gets implemented, I would use it in PreparedStatement, replacing values with "?"-s. was: I'm trying to utilize MERGE to do an upsert operation like this: MERGE INTO "APP"."ST_KEY_VAL" trg USING (SELECT * FROM (VALUES ('key1', 'val1')) as t1 (st_key, st_val)) as src ON st.st_key = src.st_key WHEN MATCHED THEN UPDATE SET st_val = src.st_val WHEN NOT MATCHED THEN INSERT VALUES (src.st_key, src.st_val) ; Derby returns an error: Error: The source table of a MERGE statement must be a base table or table function. SQLState: 42XAL ErrorCode: 30000 MERGE is used this way on other databases, unfortunately I can't find whether it is standard compliant or not. If this gets implemented, I would use it in PreparedStatement, replacing values with "?"-s. > Allow derived table as a source in MERGE statement > -------------------------------------------------- > > Key: DERBY-6723 > URL: https://issues.apache.org/jira/browse/DERBY-6723 > Project: Derby > Issue Type: Improvement > Components: SQL > Affects Versions: 10.11.1.1 > Reporter: Aleksei Kovura > Priority: Minor > > I'm trying to utilize MERGE to do an upsert operation like this: > MERGE INTO "APP"."ST_KEY_VAL" trg USING (SELECT * FROM (VALUES ('key1', 'val1')) as t1 (st_key, st_val)) as src > ON trg.st_key = src.st_key > WHEN MATCHED THEN UPDATE SET st_val = src.st_val > WHEN NOT MATCHED THEN INSERT VALUES (src.st_key, src.st_val) > ; > Derby returns an error: > Error: The source table of a MERGE statement must be a base table or table function. > SQLState: 42XAL > ErrorCode: 30000 > MERGE is used this way on other databases, unfortunately I can't find whether it is standard compliant or not. If this gets implemented, I would use it in PreparedStatement, replacing values with "?"-s. -- This message was sent by Atlassian JIRA (v6.2#6252)