Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 1930 invoked from network); 15 Sep 2006 02:44:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Sep 2006 02:44:24 -0000 Received: (qmail 43133 invoked by uid 500); 15 Sep 2006 02:44:22 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 43103 invoked by uid 500); 15 Sep 2006 02:44:22 -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 43092 invoked by uid 99); 15 Sep 2006 02:44:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 19:44:22 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of francois.orsini@gmail.com designates 64.233.182.187 as permitted sender) Received: from [64.233.182.187] (HELO nf-out-0910.google.com) (64.233.182.187) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 19:44:14 -0700 Received: by nf-out-0910.google.com with SMTP id n29so2255648nfc for ; Thu, 14 Sep 2006 19:43:46 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=gv+LB6ekb+ymHxdyrhYlyvQ/tOsQItHRGvMgGrHEvHSCZ1jOcCwFh+bRlz7ZmXcxa27Wz3E7+5w5C1ubPjjGHIxJjRQIbiyAEda8HH5fOuUJQIvWnKDm7v63HOYprMl1xFqXq8MJnTe2ZU3g1F1ZOleLPLe7g88w4/49XnrQ66o= Received: by 10.48.14.4 with SMTP id 4mr12784255nfn; Thu, 14 Sep 2006 19:43:46 -0700 (PDT) Received: by 10.48.207.14 with HTTP; Thu, 14 Sep 2006 19:43:46 -0700 (PDT) Message-ID: <7921d3e40609141943n4a975543n2f498a2fe29f4b13@mail.gmail.com> Date: Thu, 14 Sep 2006 19:43:46 -0700 From: "Francois Orsini" To: "Derby Discussion" Subject: Re: Top 1 - Limit 1 In-Reply-To: <005701c6d864$b8c2ef30$6401a8c0@matkins> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_333860_17799487.1158288226587" References: <005701c6d864$b8c2ef30$6401a8c0@matkins> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_333860_17799487.1158288226587 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/14/06, Marl Atkins wrote: > > This would only work if the ID field is an Identity. > As it happens, it IS so this should work for me too. > > THREE answers to my problem. That's one of the nice aspects of Open Source You get Open Assistance :) or Open Support however you want to call it. You guys are good THANKS!! > > -----Original Message----- > From: Dan Scott [mailto:denials@gmail.com] > Sent: Thursday, September 14, 2006 7:28 PM > To: Derby Discussion > Subject: Re: Top 1 - Limit 1 > > I think the IDENTITY_VAL_LOCAL() function is what Marl is actually looking > for. http://db.apache.org/derby/docs/10.1/ref/rrefidentityvallocal.html > > Dan > > On 14/09/06, Bernt M. Johnsen wrote: > > Marl Atkins wrote: > > > Hi: > > > > > > I'm searching the docs and can't find it. > > > Is there a way to limit the number of records in the result like: > > > > > > Sql Server: Select Top 1 * From MyRecs ORDER BY ID DESC > > > MySql: Select * From MyRecs ORDER BY ID DESC LIMIT 1 > > > > > > Basically, I need the ID of the last record inserted. > > > How can I get that? > > > > e.g. by calling stmt.setMaxRows(1); > > > > but it will not give you the *last* record inserted (SQL is a set > > language!). It will give you the row with the *highest* ID. > > > > What about > > > > select * from MyRecs where ID in (select max(ID) from MyRecs) > > > > > > > > > > Marl K. Atkins > > > Microsoft Certified Professional > > > SoftLink Systems, Inc. > > > (407) 388-1886 > > > > > > > > > -- > > Bernt Marius Johnsen, Database Technology Group, Staff Engineer, > > Technical Lead Derby/Java DB Sun Microsystems, Trondheim, Norway > > > > ------=_Part_333860_17799487.1158288226587 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 9/14/06, Marl Atkins <marl@softlinksys.com> wrote:
This would only work if the ID field is an Identity.
As it happens, it IS so this should work for me too.

THREE answers to my problem.

That's one of the nice aspects of  Open Source

You get Open Assistance :) or Open Support however you want to call it.

You guys are good THANKS!!

-----Original Message-----
From: Dan Scott [mailto: denials@gmail.com]
Sent: Thursday, September 14, 2006 7:28 PM
To: Derby Discussion
Subject: Re: Top 1 - Limit 1

I think the IDENTITY_VAL_LOCAL() function is what Marl is actually looking
for. http://db.apache.org/derby/docs/10.1/ref/rrefidentityvallocal.html

Dan

On 14/09/06, Bernt M. Johnsen < Bernt.Johnsen@sun.com> wrote:
> Marl Atkins wrote:
> > Hi:
> >
> > I'm searching the docs and can't find it.
> > Is there a way to limit the number of records in the result like:
> >
> > Sql Server: Select Top 1 * From MyRecs ORDER BY ID DESC
> > MySql:      Select * From MyRecs ORDER BY ID DESC LIMIT 1
> >
> > Basically, I need the ID of the last record inserted.
> > How can I get that?
>
> e.g. by calling stmt.setMaxRows(1);
>
> but it will not give you the *last* record inserted (SQL is a set
> language!). It will give you the row with the *highest* ID.
>
> What about
>
> select * from MyRecs where ID in (select max(ID) from MyRecs)
>
>
> >
> > Marl K. Atkins
> > Microsoft Certified Professional
> > SoftLink Systems, Inc.
> > (407) 388-1886
> >
>
>
> --
> Bernt Marius Johnsen, Database Technology Group, Staff Engineer,
> Technical Lead Derby/Java DB Sun Microsystems, Trondheim, Norway
>


------=_Part_333860_17799487.1158288226587--