In this section, you experiment with increasing the size of a transaction.

To see the effect of removing the DO TRANSACTION block from saveOrder:

  1. Comment out the DO TRANSACTION statement and the matching END statement at the end of the procedure.
  2. Recompile and generate a new listing file.
  3. Take a look at the final section. You can see that, without the DO TRANSACTION block, the entire saveOrder procedure become a transaction block:
         File Name       Line Blk. Type   Tran            Blk. Label            
    -------------------- ---- ----------- ---- --------------------------------
    .\h-OrderLogic.p       84 Procedure   No   Procedure fetchOrder             
    .\h-OrderLogic.p      107 For         No                                    
    .\h-OrderLogic.p      123 Procedure   Yes  Procedure saveOrder              
        Buffers: bUpdateOrder
                 sports2020.Order
    
    .\h-OrderLogic.p      142 Do          No                                    
    .\h-OrderLogic.p      146 Do          No                                    
    .\h-OrderLogic.p      150 Do          No                                    
    .\h-OrderLogic.p      157 For         Yes                                   
        Buffers: sports2020.OrderLine
                 bUpdateOline

Why did this happen? A DO block by itself, without a TRANSACTION or ON ERROR qualifier, does not start a transaction. Therefore, the AVM has to fall back on the rule that the entire procedure becomes the transaction block. In this particular case, this does not really make a big difference because the update code for Order and OrderLine is essentially the only thing in the procedure. But, as emphasized before, this is a very dangerous practice and you should always avoid it. If you generate a listing file and see that a procedure is a transaction block, you need an explicit transaction within your code. In fact, you should always have explicit transaction blocks in your code and then verify that statements outside that block are not forcing the transaction to be larger than you intend.