Reply-To: "Mike Dwyer" <dwyermj@co,larimer.co.us>
From: "Mike Dwyer" <dwyermj@co,larimer.co.us>
Newsgroups: comp.databases.oracle.tools
References: <39DB8A78.679F8ECD@intervoice.com>
Subject: Re: How do I retrieve last rec in a table?
Lines: 43
Organization: Larimer County, Colorado
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <iuNC5.1$9j1.134@wdc-read-01.qwest.net>
Date: Wed, 4 Oct 2000 15:35:47 -0600
NNTP-Posting-Host: 204.133.54.49
X-Complaints-To: news-admin@qwestip.net
X-Trace: wdc-read-01.qwest.net 970695694 204.133.54.49 (Wed, 04 Oct 2000 15:41:34 MDT)
NNTP-Posting-Date: Wed, 04 Oct 2000 15:41:34 MDT


change the order by to where service_provider_id = (select
in/max( service_provider_id) from service_providers)

actually, inside your form (I assume that's what you mean by Dev2k), you can
use the built-in procedure Last_record to navigate right to the last record
in the block.

Still, your pl/sql code has me wondering. You are looping through all
service providers in order by id. Your first dbms_output will be the lowest
id; the last will be the highest. Why are you using dbms_output *inside* the
loop if you only want the last value?

"dniel navarro" <dnavarro@intervoice.com> wrote in message
news:39DB8A78.679F8ECD@intervoice.com...
>
> This may be a dumb question, but how do you get the last record in a
> table.  I would like to implement this feature in my Dev2K App where
> the user will hit a button and depending on the datablock hs/she is
> focused in on, the app will take them to the last record.  I figured out
>
> how to get to the first record, but I'm stumped on how to retrieve the
> last one.  This is my code so far that gets me to the last record...
>
> declare
> cursor cur_x is
>   select
>     service_provider_id,
>     provider_name
>   from service_providers
>   order by service_provider_id;
>
> begin
>   dbms_output.enable;
>   for rec_x in cur_x loop
>     dbms_output.put_line ('service provider id: ' ||
> rec_x.service_provider_id);
>   end loop;
> end;
>
> NOTE: I'm using Oracle Server 8.0.5 on Solaris.  Developer2K Rel.2.1
>



