Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: how to loop through fields in cursor?
On Fri, 4 Jun 2004 14:48:50 +0200, "Wojtek" <new_wir_at_poczta.onet.pl>
wrote:
>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
>
>
>
>
Well you have varrays of course, but that would require a table
redesign.
Frankly, I think the table need to be designed anyway: there is no
proper design present right now.
Other than that: design errors can't be repaired by code.
-- Sybrand Bakker, Senior Oracle DBAReceived on Fri Jun 04 2004 - 14:38:30 CDT
![]() |
![]() |