Re: How do I retrieve last rec in a table?

From: Mike Dwyer <dwyermj_at_co,larimer.co.us>
Date: Wed, 4 Oct 2000 15:35:47 -0600
Message-ID: <iuNC5.1$9j1.134_at_wdc-read-01.qwest.net>


[Quoted] 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_at_intervoice.com> wrote in message news:39DB8A78.679F8ECD_at_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
>
Received on Wed Oct 04 2000 - 23:35:47 CEST

Original text of this message