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: for loop in PL/SQL

Re: for loop in PL/SQL

From: <markp7832_at_my-deja.com>
Date: Fri, 27 Aug 1999 13:44:46 GMT
Message-ID: <7q64oc$i7v$1@nnrp1.deja.com>


In article <7q4jsa$g8j$1_at_nnrp1.deja.com>,   Nandakumar <N.Kumar_at_rocketmail.com> wrote:
>
>
> Is there a way in PL/SQL to loop thru' a varchar2 list.
>
> Currently, the following snippet of code
>
> for count 1..5
> loop
> end loop; is valid in PL/SQL; count being an integer.
>
> i want to do similar thing with a list of varchar2 fields like
>
> for value in 'A' 'B' 'C'
> loop
> end loop;
>
> how can i do this? Any suggestions???
>
> thanks
> Nanda
>
> --
> Nandakumar
> (N.Kumar_at_rocketmail.com)
>

If I understand the general grist of what you are trying is to compare a column value against a list of possible values then I can think of two possibilities.

First, there is no way to write the counter for loop using a varchar2, but you can write a for cursor loop if the values you want to compare against are in a table column or you can use a pl/sql table, i.e., index by table, if you can hardcode the values.

Here is some chopped code with examples of each: (The code looks for Oracle id in one table that are no longer valid in Oracle and stores them in the index by table)

I hope this helps, and if I missed the point of what you are trying to do them please repost.
--
Mark D. Powell -- The only advice that counts is the advice that  you follow so follow your own advice --

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Fri Aug 27 1999 - 08:44:46 CDT

Original text of this message

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