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: Previous record and next record in pl/sql

Re: Previous record and next record in pl/sql

From: <andreas.prusch_at_sintec.de>
Date: Fri, 10 Jul 1998 06:57:55 GMT
Message-ID: <6o4e1j$1pm$1@nnrp1.dejanews.com>


You can use the following table operation to navigate in the table:

DECLARE
  TYPE TAB_TYP IS TABLE OF NUMBER INDEX BY BINARY INTEGER;

  Tab     TAB_TYP;
  Idx     BINARY_INTEGER;

  Idx1 BINARY_INTEGER;
  Idx2 BINARY_INTEGER;
  Ex BOOLEAN;
  Count INTEGER;
  TabContents NUMBER;
BEGIN
  Idx := Tab.FIRST; -- Now, Idx is the first index in the table   Idx1 := Tab.NEXT(Idx) -- Now, Idx1 is the following index of Idx   Idx1 := Tab.PRIOR(Idx) -- Now, Idx1 is the previous index of Idx   Idx := Tab.LAST; -- Idx is now the last index of Tab
  Tab.DELETE; -- Deletes the whole table
  Tab.DELETE(Idx); -- Deletes element with index Idx
  Tab.DELETE(Idx1, Idx2); -- Deletes the elements between Idx1 and Idx2
  Ex := Tab.EXISTS(Idx); -- Test for existance of element with index Idx   Count := Tab.COUNT; -- The number of elements in tab

   TabContents := Tab(Tab.PRIOR(Idx)); -- previous c    TabContents := Tab(Tab.NEXT(Idx)); -- next c END; Hope this will help
Andreas Prusch

In article <6o2cno$nla$1_at_thorn.cc.usm.edu>,   rsurabhi_at_orca.st.usm.edu (Rajeshwar Rao Surabhi) wrote:
> Hi all,
> I need an help to get an idea of how to do the following task. I
> used pl/sql tables but of no help. There ia a table 'a' with columns
> a,b,c,d,e. Suppose if i encounter the value for d='e', i want to select
> the previous record's column 'c', present rcords column 'c' and the next
> record's column c. I have iterate this to entire table.
>
> The output is to look like this:-
>
> a, b previous 'c' present 'c' next 'c'
> - - ---------- ---------- --------
>
> Any help is greatly appreciated.
>
> Thanks in advance
> --
> ******************************************************************************
> RAJESHWAR PH: 601-296-0937
> 201, N 34TH AVE, APT # 3 E-MAIL: rsurabhi_at_orca.st.usm.edu
> HATTIESBURG, MISSISSIPPI
> MS-39401
> (OR)
> USM BOX 5850, USM
> HATTIESBURG,
> MS 39406
>



>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Fri Jul 10 1998 - 01:57:55 CDT

Original text of this message

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