Mid-Michigan Computer Consultants, Inc.
509 Center
Bay City, Michigan

Sales (989) 892-9242             Support (989) 686-8860

ANSI Standard PL/B Language


Transactions were introduces in version 9.0.

The following is from the PL/B Forums as written by Matthew:
Subject: Transactions....migrating technique
Article #11568 - 05/04/05 12:14 PM

In talking with some users, I'm finding many people who almost need transactions are wary about implementing them. It seems mainly because they don't fully understand how they work. One user commented that they cannot use transactions because the duration of the transaction will make the system performance unusable.

So, Here is a quick tip in migrating to transactions.

Many, many,...., programs use FILEPI 99;{list} ...update all files... FILEPI 0 in order to update their files. This is perfectly acceptable practice. This type of code is also very easy to migrate to transactions. Simply change the FILEPI 99 to a TRANSACTION START and the FILEPI 0 to a TRANSACTION COMMIT.

This simple change gives you all the benefits of transactions ( preventing inconsistent files because of io errors, etc ) without effecting the performance of your application. This is because existing code already locks the files involved in the transaction for the necessary duration. Nothing else changes.

It seems users have this perception that a transaction should be used to cover an entire process, but that simply isn't the case. A transaction should be used whenever two or more files need to be updated to maintain consistancy in the data. Which is exactly where filepi is recommended to be used.

So the question now is, when do I use filepi and when do I use a transaction?

A filepi should be used on a control file while a record is being updated that can effect other processes. For example, many programs use a file that has a series of sequential counters and only one client should use any given value. Here FILEPI is ideal:
      filepi  3,controlfile
      read  controlfile,zero;controlrec
      incr   controlrec.invoicenum
      update controlfile;controlrec 
A transaction should be used in logic where multiple files are being updated:

Using this approach, the transaction does not have to cover processing the entire invoice, but only the files necessary for a given record of the invoice. This way, the files are kept in a consistent state and resuming a crashed process becomes much simpler since you don't have to worry about records added here that aren't reflected there, etc. If an IO error occurs in the overall process, the files remain consistent in what was successfully processed rather than trying to identify where in the update logic the error occurred.

For many people, this will be a simple matter of changing the filepi statements to transaction statements.


Send e-mail to MMCC.

Write to MMCC Technical Support at:
MMCC, Inc.
600 W. Midland
Bay City, MI 48708
(989) 686-8860
| Home   |

© 1997 - 2003 MMCC, Inc. All Rights Reserved.
Report problems or suggestions to