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 -> how to loop through fields in cursor?

how to loop through fields in cursor?

From: Wojtek <new_wir_at_poczta.onet.pl>
Date: Fri, 4 Jun 2004 14:48:50 +0200
Message-ID: <c9pr53$lvt$2@pippin.warman.nask.pl>


Hi,

Is there a way to access cursor column by its position not by its name? I have opened cursor with over 200 fields and I would like to loop through it and get the value of each field into the separate index of tabletype variable.
Right now I have some dreadful code :

OPEN C FOR SQLSTRING;
LOOP
    FETCH C INTO W(1), W(2), ...... and so on up to W(200);    EXIT WHEN C%NOTFOUND;
... do something

END LOOP; Taking into consideration this cursor can consist of 500 fields next month (for example) it woud be better to
OPEN C FOR SQLSTRING;
LOOP
    FETCH C INTO some%rowtype_variable;

        for i in 1 .. total_number_of_fields
            W(i) := some%rowtype_variable.fields(i)
        end loop;

   EXIT WHEN C%NOTFOUND;
... do something

END LOOP; Is it possible to do something like this? I cant find any information about that.

Thanks in advance for any help.

Regards,
Wojtek Received on Fri Jun 04 2004 - 07:48:50 CDT

Original text of this message

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