Incrementing a letter instead of anumber

Hello, is there a way to increment a letter instead of a number?

Like if I have a document_rev_cd column that needs to be incremented to the next letter like:
'A' and then the next record will have 'B' and then 'C', etc.

Kind of like 1, 2, 3, 4

I am writing pl/sql code where it checks to see if there is a document_rev_cd exists and if it does,
then get that value and increment it to the next letter in the alphabet.

--check to see if document_rev_cd has a value
if length(document_rev_cd) >1 then
     --increment the rev_cd to the next value or letter in the alphabet
     document_rev_cd :=  --this would increment to 'B', if the document_rev_cd was 'A'
end if;


Oracle 11g
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if it's one character you want incremented you can just increment the numeric value then turn that value back into a character

document_rev_cd := chr(ascii(document_rev_cd)+1);

if your string is more than one character,  what does that data look like and what do you want to do if your strings look like AZ or ZZ or 1Z?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MachinegunnerAuthor Commented:
Thanks, yes, it is only 1 character long for this document_rev_cd.
length(document_rev_cd) >1

if the string is only one character, that condition will always be false

also, note the code above will increment Z out of the alphabet
MachinegunnerAuthor Commented:
Thanks for the reply.
If that length(  ) >1 will not work, what would work instead?
would I need to write my own function?  I could not find anything
on this subject within oracle to check if a value exists.

104 on the increment of 'Z'.  I don't believe it would go that high...  but
you'd never know..  :-)
document_rev_cd is not null


length(document_rev_cd) = 1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.