Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating complaint number automatically

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to generate a complaint number in database to a calling person.how can i do this?

Thanks.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by preethi Ayyappan:
Hi,
I need to generate a complaint number in database to a calling person.how can i do this?

Thanks.


Pl elaborate it a little more ? What do you want to do ?
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a customer want to make a complaint registration to a bank through phone,a complaint number should be generated automatically for that particular customer in the database.How can i do this?
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want that to be the primary key in your complaint table?

Try a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it should not be a primary key.can i update the complaint number using update query if the customer wants to register a complaint?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You can do this either using a database specific mechanism. You don't mention the database type, but you could use a sequence, or an identity column, or an autoincremenet column, or a timestamp colum depending on the database. Or you can do this in your app. Its easy enough to do that - you'll need to use some sort of pattern (for example the HILO key generation pattern) to get a value and just update the database accordingly.

If you have an entity that needs a unique, unchanging, not null complaint number; is that not a primary key?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic