in reply to Re: EZDBI is an easier interface to SQL databases
in thread EZDBI is an easier interface to SQL databases
eval { UPDATE ... } or INSERT ...;introduces a potential race condition. If two processes are simultaneously trying to update-or-insert a row using that technique then the following can happen:
(initially the row is not there) process A: UPDATE fails process B: UPDATE fails process A: INSERT succeeds process B: INSERT failscausing an unexpected failure in one of the processes. It's safer to do it the other way around:
eval { INSERT ... } or UPDATE ...;which ought to be safe, because a successful INSERT will lock the affected row. I think this difficulty nicely illustrates the advantage of having a REPLACE option in EZDBI, though it would have to be implemented slightly differently for each different type of database.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: INSERT or UPDATE
by Dominus (Parson) on Oct 10, 2001 at 20:15 UTC |