Lock all the databases first, then update them. I'm pretty sure all SQL 
databases have the ability to lock tables. In mySQL the sequel is:

LOCK TABLES
tbl_name [[AS] alias] lock_type
    [, 
tbl_name [[AS] alias] lock_type
] ...

lock_type:
    READ [LOCAL]
  | [LOW_PRIORITY] WRITE


UNLOCK TABLES

Now if anything goes wrong in between that causes an execution failure then 
that is obviously very bad. So you want to put your code  that updates the 
databases in a try/catch control structure, and in the catch, before any 
interaction with the user, unlock tables. I'm pretty sure if it's a disconnect 
problem, the SQL database will terminate the connection and drop all the locks 
you set automatically. 

Bob


On Apr 29, 2011, at 9:24 AM, Nonsanity wrote:

> So you have data in memory that is constantly being updated, and need to
> save the data to several databases periodically. But when you save to each
> database in sequence, the data could be updated in between them, causing the
> databases to be out-of-sync.
> 
> So what you could do is snapshot the data in memory by making a copy of it,
> then use the static copy to write to each database in turn. This keeps them
> safe from the continuous updates.
> 
> 
> ~ Chris Innanen
> ~ Nonsanity
> 
> 
> On Sat, Apr 23, 2011 at 11:12 AM, Glen Bojsza <gboj...@gmail.com> wrote:
> 
>> Hello,
>> 
>> I have a database which I have created several queries for doing archival
>> reports.
>> 
>> Now I would like to have all the queries update the reports automatically
>> every 10 seconds.
>> 
>> From what I determined I will need to keep the database connections open
>> while the application is running but I cannot do sequential queuing of the
>> queries because by the time the last query runs it will be out of sync with
>> the earliest query.
>> 
>> So, what is the best method to have all queries update every 10 seconds in
>> parallel? Each query will have it's own database connection that is open.
>> 
>> For anyone not doing databases this could be a similar problem in nature
>> where one needs to have multiple events for gaming occur in parallel... I
>> have not tried programming any games or anything else surrounding this type
>> of parallism.
>> 
>> thanks,
>> 
>> Glen
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to