IntelliJ Java IDE
The moose likes Oracle/OAS and the fly likes How to generate Fixed length Sequences ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "How to generate Fixed length Sequences ? " Watch "How to generate Fixed length Sequences ? " New topic
Author

How to generate Fixed length Sequences ?

shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 182
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

Joined: Apr 14, 2004
Posts: 10336

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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Agador Paloi
Ranch Hand

Joined: Jan 24, 2006
Posts: 114
I would agree with Paul . Maybe have your country code as a seperate column from your sequence.

Agad
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 182
I understand and thanks alot
 
 
subject: How to generate Fixed length Sequences ?
 
Threads others viewed
what i will use in hbm when we use sequence at backend side ?
generating secure tokens
autogenerated keys
Generate next hexadecimal?
Generate unique numbers from a table's primary key, to be used as an external reference.
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture