Home » RDBMS Server » Server Administration » Re: current value vs. next value
Re: current value vs. next value [message #370243] Thu, 27 May 1999 08:44 Go to next message
Chris Hunt
Messages: 27
Registered: March 1999
Junior Member
There's no explicit current/next value properties for cursors, so you have to do it yourself something like...
DECLARE
   CURSOR c1 IS
      SELECT columnA,
             columnB
      FROM   table;
   prev_rec  c1%ROWTYPE;
BEGIN
   FOR my_rec IN c1 LOOP
      IF my_rec.columnB = prev_rec.columnB THEN
         Statement
      ELSE
         Statement 
      END IF;
      prev_rec := my_rec;
   END LOOP;
END;

Note that I compare each record with the previous one rather than the next, so you may need to read the table in reverse order.

Re: current value vs. next value [message #370245 is a reply to message #370243] Thu, 27 May 1999 15:19 Go to previous message
tatjana
Messages: 1
Registered: May 1999
Junior Member
Thanks a lot Chris for such a fast respond and that elegant solution for my problem.
Previous Topic: Re: Insert into table...
Next Topic: Re: Insert into table...
Goto Forum:
  


Current Time: Wed Oct 28 06:21:50 CDT 2020