Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using Max for Alphanumeric values

911012Jun 12 2012 — edited Jun 12 2012
Current i have a varchar2 column with the following data
NPT_Code
NPT00001
NPT00112
NPT03019A
NPT00419
Trying to figure a way to strip all the letters and get the next increment of the highest value.

Digits are always fix to 5. There always 3 letters to the left. and sometimes there is a letter to the right.

I was going to mak a sequence and manually looking for the highest number in that column and just start from there but i was wondering if anyone else knows another solution that uses max or something simliar.
Select Max(NPT_Code) + 1 into l_NPT_CODE FROM TABLE

UPDATE TABLE
SET NPT_CODE = L_NPT_CODE
WHERE ID = XXXX;
This post has been answered by Frank Kulash on Jun 12 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 10 2012
Added on Jun 12 2012
7 comments
2,179 views