aspose file tools*
The moose likes Oracle/OAS and the fly likes How to generate Fixed length Sequences ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
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: 200
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: 118
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: 200
I understand and thanks alot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to generate Fixed length Sequences ?
 
Similar Threads
autogenerated keys
what i will use in hbm when we use sequence at backend side ?
Generate next hexadecimal?
Generate unique numbers from a table's primary key, to be used as an external reference.
generating secure tokens