Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 1238 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

Hello Forum,

Im writing a script for my locally hosted FM Database that will manipulate quite a few records in the database.

Basically when a user changes the name of an item to something they type in, I must go into several tables to change other values depending on what was typed in accordingly. In a nutshell I must enter 2-3 tables, do a find, modifiy the records and then do the same on the next table and so on.

All that is no problem. The question I have is this:

How can I make this procedure, "indivisible"? What I aim to achieve is that while this routine is running, noone will interfere with it. If another user changes the name of the item at aroundabout the same time, the whole thing could fail, because then all the finds and mods will get confused with one another.

For situations like this im always used to creating a field that I use as a semaphore. At the start of the script I set a flag in that field, and if someone else wants to execute the script at the same time, the scrip will refuse because the semaphore is set.

However I wonder how elegant that is (both scripts could still try to set the semaphore at the same time?).

Is there a way I can let the OS handle this? Would it help if I execute the script on the server? Disallow script Aborting?

How can I make the script as indivisible as possible so that only one person can run it at any one given time, and were pretty much guaranteed that?

Is there a way to do that at all?

Thanks for ideas!

Spongebob

 

 

Edited by spongebob
Posted

Thanks for your suggestion bcooney! "Why is the data repeated across tables?" ah the key question ;) of course, in a perfect world it shouldnt be (3rd normal form and all that we are very aware); however this is a quite large and highly complex DB with many different functions where certain functions can only be achieved at speed by repeating some small amounts of the data. Otherwise, if you link everything with live indexes (which is possible) and the DB gets large, it slows down too much after around 1 million records in some tables. So; repeating the info in some fields keeps it nice and fast. The downside is of course the tedious maintenance in the scripts; but we accept that to keep things moving.

Ill read your article now thank you for your help!

best

Spongebob

Posted (edited)

Okay ive read the Article on Transactions. Whilst thats groovy; Im not sure how it will help.

Say I write my script so that everything is packed into a single transaction which i commit at the end.

Im unsure if I understand how will this help me?

Lets say 2 users both start the procedure at the exact same time by clicking the button.

If i understand it correctly that means that the first commit of the first transaction cannot be interrupted by the other?

ie - Both transactions will be eventually done, but it is then guaranteed that one happens after the other yes?

 

 

Edited by spongebob
Posted (edited)

You are talking about two different things as if they were one. 

Making sure only one user can run the same script at the same time is one thing. This could be accomplished easily as you suggested yourself, by using a "script in use" flag.

Making sure no one will interfere with what the script does is something else. Other users can interfere in other ways besides running the same script. If you want the entire script to be one indivisible transaction, you must make sure all affected records are successfully opened and locked by the script before any actual action takes place. This is considerably more difficult to implement.

 

Edited by comment
  • 9 months later...
Posted

Thank you all too that really did help! Sorry replying so late!

This topic is 1238 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.