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

From: dniel navarro <dnavarro_at_intervoice.com>
Date: Wed, 04 Oct 2000 17:12:25 -0500
Message-ID: <39DBAB49.2CA4F97D_at_intervoice.com>


Oops! I forgot to take out that piece of code that was spooling out to the dbms_output. It was there just to see what was going on inside the loop. Thanks for the hint!

Mike Dwyer wrote:

> 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 Thu Oct 05 2000 - 00:12:25 CEST

Original text of this message