Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Q:SQL:How to update pagenumbers
On Sun, 11 Oct 1998 21:43:25 +0200, Ralf Bender
<Ralf.Bender_at_wolnet.de> wrote:
>Hello *.*
>i've got a high problem in my little opinion.
>there is a table like this :
>
>company number page timestamp(MM.DD.YY)
>11 123 1 07.09.98
>11 123 2 07.09.98
>11 123 1 09.09.98
>11 123 2 09.09.98
>
>
>now, i must renumber the page of the youngest records.
>the table must look like this :
>
>company number page timestamp(MM.DD.YY)
>11 123 1 07.09.98
>11 123 2 07.09.98
>11 123 3 09.09.98
>11 123 4 09.09.98
>
>
>Is there somebody who can help me ?
Using PL/SQL you can use the procedure ...
create or replace
procedure reorder_page is
l_idx number := 1; l_comp number := -1; l_num number := -1;
from T1 order by company, num, timestamp )loop
l_idx := 1; l_comp := c.company; l_num := c.num;
eg.
SQL> select * from t1;
COMPANY NUM PAGE TIMESTAMP
---------- ---------- ---------- --------- 11 123 1 07-SEP-98 11 123 2 07-SEP-98 11 123 1 09-SEP-98 11 123 2 09-SEP-98
SQL> exec reorder_page
PL/SQL procedure successfully completed.
SQL> select * from t1;
COMPANY NUM PAGE TIMESTAMP
---------- ---------- ---------- --------- 11 123 1 07-SEP-98 11 123 2 07-SEP-98 11 123 3 09-SEP-98 11 123 4 09-SEP-98
SQL> hope this helps
chris. Received on Wed Oct 14 1998 - 08:50:39 CDT