Multiple users

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
charliejo
Posts: 11
Joined: Mon 02 Jan 2006 12:53

Multiple users

Post by charliejo » Thu 19 Jan 2006 07:58

Hello,
If 2 users update in the same time the same records,how MyDAC resolve the problem?
Is it possible to lock the record when the first user update it... and the second user must wait the record be free?

Thanks

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 19 Jan 2006 15:18

Yes it's possible. Please see Mydac\Demos\Win32\Lock\ for example.

charliejo
Posts: 11
Joined: Mon 02 Jan 2006 12:53

Post by charliejo » Thu 19 Jan 2006 16:03

I develop with C++ builder 6. I used code of demo in my application , but it doesn't work. The record isn't lock .
I used MyISAM table.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 20 Jan 2006 15:02

If the second user had applied Lock with lrImmediately parameter, the other users can't perform any changes with locked record at all. But if they both open the same table and then the first user deletes a record, the second user is not notified of record deletion. To avoid editing deleted record, you should try to lock record before editing and catch error using try...except block.

oquz
Posts: 11
Joined: Mon 02 Jan 2006 15:16

if i use second transaction, first transaction canceled.

Post by oquz » Sat 21 Jan 2006 08:33

if i use second transaction, first transaction canceled.

i want to record lock and multi transaction.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 23 Jan 2006 15:09

We can't understand your problem exactly. If you want to use more than one transaction using one MyConnection, it's nested transactions. Nested
transactions are not supported by MySQL Server. Quotation from MySQL manual: "Transactions cannot be nested. This is a consequence of the implicit COMMIT performed for any current transaction when you issue a START TRANSACTION statement or one of its synonyms."
Try to use more MyConnection instances. If transaction that locked a record was rolled back, the record automatically gets unlocked

oquz
Posts: 11
Joined: Mon 02 Jan 2006 15:16

one connection one active transaction.

Post by oquz » Tue 24 Jan 2006 11:49

one connection one active transaction.

but i want to one connection multi active transaction.
this problem is belong to mysql.

thanks ikar.

Post Reply