RE: Increment an alphabetic variable in a PL/SQL loop?

  • From: "Klonicki, Stephen A" <SKLONICK@xxxxxxxxxxxxxxxxxxx>
  • To: "'Oracle-L@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 3 Dec 2009 10:34:59 -0500

pretty much what folks are saying.   My example may be overkill but hope it is 
helpful:

declare
letter char;
begin
  for lcv in ascii('A')..ascii('Z') loop
    letter := chr(lcv);
    dbms_output.put_line('lcv is at ' || letter);
  end loop;
end;
/

Replace dbms_output with your business logic.  lcv has to be numeric.


________________________________
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of japplewhite@xxxxxxxxxxxxx
Sent: Thursday, December 03, 2009 10:28 AM
To: 'Oracle-L@xxxxxxxxxxxxx'
Cc: ChrisDavid.Taylor@xxxxxxxxxxxxxxx
Subject: Re: Increment an alphabetic variable in a PL/SQL loop?

Chris,

Use the Chr(xx) function and increment the xx digit argument.  Chr(65) = A, 
Chr(66) = B, and so on.

Jack C. Applewhite - Database Administrator
Austin I.S.D. - MIS Department
512.414.9715 (wk)  /  512.935.5929 (pager)



From:   "Taylor, Chris David" <ChrisDavid.Taylor@xxxxxxxxxxxxxxx>
To:     "'Oracle-L@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
Date:   12/03/2009 09:22 AM
Subject:        Increment an alphabetic variable in a PL/SQL loop?
Sent by:        oracle-l-bounce@xxxxxxxxxxxxx

________________________________



Hey how can we increment an alphabetic variable in PL/SQL?

Let's say I have var1 = 'A' for the first pass, but for the second pass, I want 
it to autoincrement to var1='B' and ultimately to 'Z'.

I'm searching but its hard to find the right search terms to give me what I 
want.


Chris Taylor
Sr. Oracle DBA
Ingram Barge Company
Nashville, TN 37205
Office: 615-517-3355
Cell: 615-354-4799
Email: chris.taylor@xxxxxxxxxxxxxxx<mailto:chris.taylor@xxxxxxxxxxxxxxx>


Other related posts: