MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » January 2014

Re: best practice for web client updates to multiple tables



fixed

The Requirement is to bring some records all to the database, not influenced by other activities of the database. This is called a transaction and best practice for relational databases is to use committment controll and this is veery easy!!!
- be sure your tables are journaled (OS/400 could manage complete Journalmanagement automatically)
- choose an appropriate commit level (for DB2/400 others than NONE, AUTOCOMMIT or SERIALIZABLE)
- read your records for update (to be sure they were not changed since your last read)
- make your updates
- if this all works issue commit
- if one of these fails (record changed, or locked) issue rollback

Other transactions running on the system at the same time are not influenced by this. Other programms without bugs, will run as expected. buggy programms (doing transactions without commit or equivalent technics) might behave buggy, as before!
Using commitment control, you could further on managing seeing only completed transaction (isolation level read committed).

A database transaction must not (never!!!) overlap with user transactions. If you have long lasting transactions (shopping cart). Store the data temporary (in a cooky or temp workfile or in the state of the process or in the container running your application) and if the user is finished and confirms the order, start your transaction to bring the temp data to the database. If you have to ensure, that the database transaction must not fail (flight reservation systems), you would need some reservation mechanism (status field of a dataheader, or additional reservation tables) to manage this. But in any of these cases, best practice would be to use commitment controll!

BTW: using commitment controll is best practice for native applications on as400 too and not using it, often makes programms buggy (yes buggy!!! most rpg programms I've seen in the last 20 years don't use commit and are buggy and quite a lot of them are only working correct, because they are running exclusive in batch). Record locking of RLA does not replace commitment controll, it only ensures, that a single update might work as it should!

D*B





Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact