Steve O'Hara wrote:

The audit logic is as follows;

   begin transaction
   select total from useractivity where event= .....
   If lRows = 0 Then
       insert into useractivity ......
   Else
       update useractivity .....
   End If
   commit transaction


Is useractivity.event UNIQUE? Does it use the UNIQUE keyword in the CREATE TABLE statement or do you have a UNIQUE index on that column. If so, then you might consider just doing a REPLACE instead of an INSERT. If a REPLACE will work for you then you can avoid the complication entirely.

If REPLACE does not work for you, then when the
INSERT or UPDATE fails because of a lock, you need
to do a ROLLBACK and start all over again with the
BEGIN TRANSACTION.  That will take care of your
locking problems.


-- D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565



Reply via email to