Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to generate Fixed length Sequences ?

 
shukla raghav
Ranch Hand
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want my primary key to be fixed length and it must ahev a format like

- first three characters must be Alphabets that represent the initials of a country like LON, FRA, ITL, JAP, IND etc
- Next seven characters must be unique numbers generated by the sequence.

but the sequence does not generate numbers in fixed length format. what do i do, i dont want to do too much processing for just creating a meaningful primary key.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does the key need to be meaningful? The only safe primary key will have meaning to the database, nothing else. Could you not just make your seven digit field a surrogate key and stick a unique index on both fields?

 
Agador Paloi
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would agree with Paul . Maybe have your country code as a seperate column from your sequence.

Agad
 
shukla raghav
Ranch Hand
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand and thanks alot
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic