Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 92857 invoked from network); 17 Nov 2007 01:51:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Nov 2007 01:51:15 -0000 Received: (qmail 50972 invoked by uid 500); 17 Nov 2007 01:51:02 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 50951 invoked by uid 500); 17 Nov 2007 01:51:02 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 50940 invoked by uid 99); 17 Nov 2007 01:51:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 17:51:02 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of amichail@gmail.com designates 209.85.132.251 as permitted sender) Received: from [209.85.132.251] (HELO an-out-0708.google.com) (209.85.132.251) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Nov 2007 01:50:52 +0000 Received: by an-out-0708.google.com with SMTP id c8so193156ana for ; Fri, 16 Nov 2007 17:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=6BCNi4NCWqFZ6GOVzdnSAMDStdGssvDmta4mwv9BmeU=; b=BsvrdkuKkCIKcsK+OUGq5hOreH0masYzAsYsDmltVQgZ0hLdNkWfnipcPDVEOqfle9HNpL9oTgSPbpLjN4ZL1E4lh0lmI7o+T1wpwfNQgpuyUH5UsobBYd5A9Wr24lAaaGanVCT3+iXJT7WAjbXXW7KJuNUNrZ5jgqvL2WVWHAg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OeQca4rLCX4midu15XHNDj5zf8/99pA2JCzfaHCLXaM9MD4qQksw2dxDhw1xUBsuhOTOaPD3yIrVe2gDyTzWpk+TjqSuPykwXyr8p9+fgAGIgTHqoQ8FbrdIVZR9ROoBU0c29rrAVAJMZm0vxW69UbitrIvL+o5gD9bKymlQX+0= Received: by 10.100.202.9 with SMTP id z9mr3684299anf.1195264245298; Fri, 16 Nov 2007 17:50:45 -0800 (PST) Received: by 10.100.251.4 with HTTP; Fri, 16 Nov 2007 17:50:45 -0800 (PST) Message-ID: Date: Fri, 16 Nov 2007 20:50:45 -0500 From: "Amir Michail" To: "Derby Discussion" Subject: Re: how to suppress similar rows while copying from one table to another? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <473D97D7.4020700@sun.com> <473DD4F4.6040405@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Hi, I ended up using JDBC to do this. Amir On Nov 16, 2007 8:37 PM, Dag H. Wanvik wrote: > > Daniel John Debrunner writes: > > > Rick Hillegas wrote: > > > >> One way to solve this problem would be to put a filtering function > >> in the WHERE clause of the driving SELECT statement. Something like > >> this: > >> INSERT INTO targetTable > >> SELECT * FROM sourceTable > >> WHERE isFirstInstance( tastyColumn1, tastyColumn2 ) = 1 > >> Here isFirstInstance is a function which returns 1 the first time it > >> sees a given key combination and returns 0 on all subsequent > >> sightings. You, of course, have to write this user function. > > > > Any thoughts on how to do that? Since such calls are stateless how > > would you identify it's the first call for a query execution? > > I first thought of using a tmp table containing just the two columns, > and just opening a result set on the first table, loop, and copying a > row to destination table if not present yet in tmp table, else insert > it there too. One could hide that check inside a function like Rick > suggests? > > Tried in vain to come up with a clever single INSERT, though. > > Dag >