RE: Number Generation
Posted in 2000
Like 'a_blond' said, I'm not sure what you mean by 'simplify the
situation'.
But here goes:
If you create a unique index on your table, then rather than checking if
the value is already there, you can attempt an insert. If you trap the
error, it will tell you if the value already exists.
Something like [pseudo code]:
let stat = 1
while stat != 0
let results = algorithm()
whenever error continue
insert into table values (results)
let stat = status
whenever error stop
end while
Is this any simpler?
HTH
-----Original Message-----
From: MA [mailto:hmd_mbshr@yahoo.com]
Sent: Sunday, March 26, 2000 1:09 PM
Posted To: informix
Conversation: Number Generation
Subject: Number Generation
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