Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Address last rows in a table

Re: Address last rows in a table

From: Jeremiah Wilton <jeremiah_at_wolfenet.com>
Date: Thu, 28 Jan 1999 22:45:20 -0800
Message-ID: <Pine.OSF.4.02.9901282237240.13732-100000@gonzo.wolfenet.com>

This is somewhat problematic. There is no guarantee, or even expectation, that the last 10 rows returned by the c_your_table cursor are the last 10 rows that were inserted into the table.

If you want to write a trigger, that might get you what you want.

--
Jeremiah Wilton http://www.wolfenet.com/~jeremiah

On Thu, 28 Jan 1999, Don Hall wrote:
>
> You can write a procedure to return the last 10 rows.
>
> declare
> v_row_cnt number := 0;
> v_row_tot number := 0;
> cursor c_your_table is select field1, field2 from your_table;
> begin
> select count(*) into v_row_tot from your_table;
> dbms_output.put_line(' total number of records is '||to_char(v_row_tot));
> for v_row in c_your_table loop
> v_row_cnt := v_row_cnt + 1;
> if v_row_cnt > v_row_tot - 10 then
> dbms_output.put_line('row '||to_char(v_row_cnt)||' '||v_row.field1||'
> '||v_row.field2);
> end if;
> end loop;
> end;
>
> Miguel Alves wrote:
> >
> > We have a table wich as rows without any sequence (we can't change this
> > because this is an application package) . Our problem is that we have to
> > retrieve the last n rows inserted in the table.
Received on Fri Jan 29 1999 - 00:45:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US