• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

generating Unique id with date and time in id

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have to generate unique ids to insert in oracle database as primary key for a table with time and date in the id. Many users can insert at the same time in the table.
i will purge the database records 2 months old so thinking if there are any potential problems in using auto increment kind of logic.

Will sequence in Oracle can be of any help?

Any suggestions are welcome.

Thanks in advance...
[ June 27, 2007: Message edited by: Karan Jain ]
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My advise: don't put logic in auto-generated id's.
If you need a unique id, then let Oracle's sequence mechanism generate one for you.
If you need to purge data older than two months, then create a field in your table to store the creation date.
It's better not to mix things up.
And you have a chance to write a performing purge query if the creation timestamp is in an Oracle date field, not if the date is hidden somewhere in a part of your unique id.

Regards, Jan
 
Karan Jain
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Jan,
I agree to your suggestion and using the same...
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic