Ummm...How would things work out if you tested to see whether the log contains the currently generated number before you inserted the new one? Isn't that what helloworld922 suggested a couple of...