All the transaction is going to do for you is roll back if the ID is not unique. So you still stuck determining a unique ID. I guess you could use the error if the to flag it to try again until it does go through.  There are times to invoke transactions, but that is a hefty load for this task IMHO.

We had a discussion on the list back a bit ago. See thread “Key of Record Just Written”

 

Ben Johansen - http://www.pcforge.com
Authorized Witango Reseller http://www.pcforge.com/WitangoGoodies.htm
Authorized MDaemon Mail Server Reseller
http://www.pcforge.com/AltN.htm

-----Original Message-----
From:
Atrix Wolfe [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2003 5:10 PM
To: [EMAIL PROTECTED]
Subject: Re: Witango-Talk: a question

 

do transactions help this problem at all?  Can they lock the table until the transaction comes to an end?

----- Original Message -----

From: Ben Johansen

Sent: Monday, June 02, 2003 5:05 PM

Subject: RE: Witango-Talk: a question

 

This is most definitely multi-user issue. It is not the nature of just Witango it is the nature multi user interaction in general.

 

You will need to find a way to lock the table and for the current instance so that others can’t get the next number.

 

I find it easier to create a counter table with one row and one column and then have a stored procedure do the locking and incrementing and returning of the next number

 

Ben Johansen - http://www.pcforge.com
Authorized Witango Reseller http://www.pcforge.com/WitangoGoodies.htm
Authorized MDaemon Mail Server Reseller
http://www.pcforge.com/AltN.htm

-----Original Message-----
From: Atrix Wolfe [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2003 4:40 PM
To: [EMAIL PROTECTED]
Subject: Witango-Talk: a question

 

hello, weve been having a really hard to track error and i was wondering about something.

 

We have a table w/ an integer ID that is marked as must be unique.

 

In our code, we do this to get the next id:

 

select max(ID)+1 from table

 

and then in the very next action, its a DBMS using the results of that select to insert into the table.

 

Well the error we are having is that fairly rarely, the insert DBMS will fail saying rows must be unique (and the ID is the only column marked as needing to be unique).

 

Could this be due to the multitasking nature of witango where multiple people would hit the select code and get the same ID before it does the insert?

 

Or does it finish one person's request completely before moving to the next request?

 

Anyone had any problems like this before or know how to get around it?

 

Thanks!

Atrix

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf

Reply via email to