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

Home -> Community -> Usenet -> c.d.o.misc -> Re: help me in cursors.

Re: help me in cursors.

From: <edwards_at_garland.dnr.state.sc.us>
Date: 1997/02/08
Message-ID: <32FCA6AB.59E2@garland.dnr.state.sc.us>#1/1

Srikanth Patibanda wrote:
>
> Hello,
>
> I have some problems regarding the cursors.
>
> actually i want to get more than one row from the database. so i am
> using the cursors to get it. but unfortunately i am not able to get the
> records. Yesterday i have given this email and i got one answer that i
> should use NEXT_RECORD in the loop. Even after using that i am able to
> get the records but its not showing all at a time.
>
> Actually my problem is i want to get the records and to display all on
> the screen at a time. As a normal query operates.
>
> The code i used is GIVEN BELOW
>
> NOTE: I WANT TO DISPLAY ALL THE RECORDS AT A TIME ON THE SCREEN.
>
> DECLARE
> cursor c1 is
> select st_id, sample_date, time, compid, concentration
> from analyzed_samples1
> where st_id = :segments.st_id and
> (sample_date between :segments.firstdate and :segments.lastate);
>
>
>
> BEGIN
>
> open c1;
> loop
>
> fetch c1 into :analyzed_samples3.st_id,
> :analyzed_samples3.sample_date,
> :analyzed_samples3.time,
> :analyzed_samples3.compid,
> :analyzed_samples3.concentration;
> exit when c1%notfound;
> next_record;
> end loop;
>
> close c1;
> END;
>
> I really appreciate if anyone answer my question.
>
> Thanking you
>
> SRIKANTH.PATIBANDA
Heres how I would do it:

BEGIN          open c1;

         loop
             fetch  c1 into :analyzed_samples3.st_id,
                            :analyzed_samples3.sample_date,
                            :analyzed_samples3.time,
                            :analyzed_samples3.compid,
                            :analyzed_samples3.concentration;
             if c1%NOTFOUND
             then
                  EXIT;
             else
                  -- print the data
                  DBMS_OUTPUT.PUTLINE(st_id);
             end if;
         end loop;

         close c1;

 END; Received on Sat Feb 08 1997 - 00:00:00 CST

Original text of this message

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