Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Handling Strings?

New Here ,
Jun 26, 2008 Jun 26, 2008
I'm currently working with a database, in which some primary keys are varchars. I'm supposed to make an application that creates an "automatic" primary key for each new register, currently for instance, if the max(pk) is 100, the new one is 101. My question is, how to handle strings in a way in which if max(pk) is abx, I can do abx +1 to get aby - or similar. Any comments?
177
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 27, 2008 Jun 27, 2008
LATEST
Here is how I might approach the problem:

1. See if the last set of values are numbers using a Regular Expression to look at the end of the string for numbers
2 If so, strip out those numbers into a variable and the characters into a second variable
2.1 Add 1 to the variable.
2.2. Join the second variable with new first variable to get your new number
3. If there are no numbers at the end, then append 1 to the end.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources