Increment character by string in sql
678623Jan 21 2011 — edited Jan 21 2011Hi, I want to increment letter by 1 like if its a then it should print as b , for b it should be c and so on. I tried with converting to ascii and then increasing it by 1 then it works fine for single characters but when i have input of more than one letter it does not work. Please provide directions to proceed.
SQL> desc new;
Name Null? Type
----------------------------------------- -------- ----------------------------
VAL1 VARCHAR2(5)
VAL2 NUMBER
SQL> select * from new;
VAL1 VAL2
----- ----------
a 10
b 20
c 30
d 40
abcd 50
SQL> select chr(ascii(val1)+1),val2 from new;
C VAL2
- ----------
b 10
c 20
d 30
e 40
b 50
This is the problem for row no.5 i want it to be printed as bcde and not just b. can it b done in sql or we need pl/sql . Any help is appreciated