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

  • From: "Kenneth Naim" <kennaim@xxxxxxxxx>
  • To: <ChrisDavid.Taylor@xxxxxxxxxxxxxxx>, "'Oracle-L@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 3 Dec 2009 10:30:12 -0500

You can use the chr function. Declare a variable as a number starting with
65 for capital letter A and then you can increment the variable by 1 for
each successive letter until 90 similarly 97 -122 for lowercase letters. 

 

 

Select chr(65) from dual

 

From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Taylor, Chris David
Sent: Thursday, December 03, 2009 10:21 AM
To: 'Oracle-L@xxxxxxxxxxxxx'
Subject: Increment an alphabetic variable in a PL/SQL loop?

 

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

 

CONFIDENTIALITY NOTICE: This e-mail and any attachments are confidential and
may also be privileged. If you are not the named recipient, please notify
the sender immediately and delete the contents of this message without
disclosing the contents to anyone, using them for any purpose, or storing or
copying the information on any medium.

Other related posts: