Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Counter in For loops
Use 2 conventional FOR loops
You'll need two 'counters'. One counter is within another and
for each loop increment, you convert the number value + 65 to
character (ie CHR(65) = 'A')
CREATE OR REPLACE PROCEDURE Alpha_Loop IS
ones varchar2(1); tens varchar2(1); value varchar2(2);
ones := CHR(b + 64); value := tens||ones; DBMS_OUTPUT.put_line(value);
SQL> SET SERVEROUT ON SQL> SET ARRAYSIZE 1 SQL> EXEC ALPHA_LOOP;
AA
AB
AC
AD
AE
AF
.
.
AW
AX
AY
AZ
BA
BB
BC
.
.
Its a start, my lunchtime doesn't extend to giving a full blown
procedure ;(
You'll have to adapt the procedure if you want the loop to
include 00 - 99.
HTH, Mark G
In article <8clfc2$dnb$1_at_nnrp1.deja.com>, Greg Tada
<gtada_at_hotmail.com> wrote:
>Is it possible to use a character string instead of a number as
the
>counter in a FOR loop? For example, I need a for loop that goes
>from '00' to 'ZZ'.
>
>Thanks in advance,
>Greg Tada
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
>
>
![]() |
![]() |