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;

Thanks,
MG

Oracle 11g
MachinegunnerAsked:
Who is Participating?
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.

sdstuberCommented:
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?
0

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.
0
sdstuberCommented:
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
0
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..  :-)
0
sdstuberCommented:
document_rev_cd is not null

or

length(document_rev_cd) = 1
0
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
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.