This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to generate Auto-EIN number in db ?

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What i want, whenever an admin register a new user by filling up his/her details(except EIN) it should be saved in the database(iam using sql server 2005) but with Auto-generated EIN with the format say 'P1000'.
Now when admin registers another one, it should be saved with 'P1001'. Please give me some idea in order to achieve this.

My first question is , i have a primary key field in db 'ein' to store all the EINs. What should be the type of that field. Is it going to be 'Varchar' or simple 'Int' ?
And also onLoad of the registeration page, an action will be called automatically to get the latest EIN increament by 1 in an computed text, so that the Admin can read what will be the next EIN going to be registered.

Now how can i separate 'P' and '1000' from 'P1000' , and then increment 1000 by 1 to become 'P1001' before saving it into database ?

And also let me know whether iam right in my logic or not ?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is an EIN? And can I ask, why is it important to preface the number with the letter P? Would a simple autoincremented surrogate key not be easier to use?
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!