Number Generation
Posted in 2000
Topics: General Discussion
Hi All: I'm generating a number using an **algorithm**. I want to make sure after generating every number, it should not be a previously generated number. If I generate a number and look it up in the database and come to know that it's already generated then I've to go thru the generation cycle until I find a number which is not previously generated. Is there any way to simplify the situation. Any help in this regard is greatly appreciated. Thanks, MA __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com
MA wrote: > Hi All: > > I'm generating a number using an **algorithm**. I want > to make sure after generating every number, it should > not be a previously generated number. > > If I generate a number and look it up in the database > and come to know that it's already generated then I've > to go thru the generation cycle until I find a number > which is not previously generated. > > Is there any way to simplify the situation. Any help > in this regard is greatly appreciated. You could use Informix's built in "algorithm" - SERIAL column. But, you run into some challenges when a little over 2billion rows have been inserted into your table. Or you could use a "Last number" table to give you constantly incrementing numbers (served by some function). Rudy