[thelist] SQL: insert into mutiple tables help

Jim McNulty jkmcnulty at mediaone.net
Wed Apr 11 08:54:24 CDT 2001


> Request 1 will insert the data.
> Request 2 will fail because that data already exists.
>
> If I understand everything about this situation, the user will see the
> result of request 2 (the request made last), which will be an error
message
> saying that data already exists.

This is why I love Oracle sequences.  You can pull the next ID from the
sequence (guaranteed unique) and put it in the form with the submit button.
If the user hits the button repeatedly, you will attempt multiple inserts
with the same sequence number as pk.  The first will succeed and the rest
will fail.  The fun part is that you don't need to present an error to the
user at all.  Having non-unique emails may indicate a problem, but having
the same sequence number come in twice in a row tells you that they clicked
the button twice, so you can simply ignore the db error without bothering
the user.  I'm not sure how to emulate sequences in other databases.

--Jim McNulty





More information about the thelist mailing list