How to manage updates in a multi-user environment

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Posts: 20
Joined: Mon Apr 18, 2016 10:31 am

How to manage updates in a multi-user environment

Post by » Thu Apr 28, 2016 1:40 pm

I'm currently putting together a design for a multi-user desktop application where I'm intending to populate livecode grids via SQL select statements.

It will be possible for a user to update a record within the grid which will then trigger an SQL update for that record. My problem is that it's possible another user may have updated the same record between the first user downloading a copy into the grid and performing their update.

My initial thought is to include a 'version' field in the SQL table that is incremented each time the record is updated and to check that it has not been changed between download and update - if a change is detected then I can run a comparison of the 2 versions and decide what action to take depending on what has changed where.

Does anyone use an alternative method to manage this issue or have any comments to make on this option?

Thanks for any feedback.


VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7314
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: How to manage updates in a multi-user environment

Post by FourthWorld » Thu Apr 28, 2016 3:35 pm

I've seen many multi-user apps that rely on optimistic conflict resolution, but I prefer explicit check out/check in to keep things clear and simple for both me and my users.

In workgroup solutions I've built everyone can view anything, but when a user wants to edit a record it first checks to see if the record has already been checked out by someone else. If so, it informs the user that the record is being edited by someone else and thus they're not able to check it out for editing themselves. If not, the server flags the record as checked out and the UI now allows editing. On check-in the flag is cleared after the record has been successfully written to the data store.

While this does impose an additional step for users, I haven't met a user yet who found it at all cumbersome. On the contrary, explicitly checking in and checking out records seems to work well conceptually for most users, perhaps even better than the guesswork of hoping records will not be edited simultaneously.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems:
LiveCode User Group on Facebook :

Posts: 1575
Joined: Tue May 28, 2013 2:20 pm
Location: Italy

Re: How to manage updates in a multi-user environment

Post by MaxV » Wed May 04, 2016 1:15 pm

If is just a database, not a cloud database with many replicas, the solution is simple.
Just use begin tansaction and commit.
Example of a query:

Code: Select all

...all my queries;
During a transaction nothing else can happen on the database. Consider that you can use some table cells as variables and there is the CASE statement for decisions. So you can program all in the transaction.
Livecode Wiki:
My blog:
To post code use this:

Post Reply

Return to “Databases”