HP 3000 Manuals

TRANSACT Command [ HP ALLBASE/4GL Developer Reference Manual Vol. 2 ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Reference Manual Vol. 2

TRANSACT Command 

The TRANSACT command enables you to define logically connected groups of
KSAM file, HP ALLBASE/SQL table, and HP TurboIMAGE/iX data set
modification commands that constitute one transaction.

Formats 

         {*BEGIN}
TRANSACT {*END  } [message]
         {*MEMO }
         {*UNDO }

Parameters 

message 

A comment, made up of any characters except semicolons.

Description 

The TRANSACT command allows you to define logical groups containing file
modification commands that are interdependent.  That is, groups of
commands where if one file modification command in the group is executed,
then all file modification commands in the group must be executed to
maintain logical consistency.  The *BEGIN and *END arguments define the
beginning and end of the transaction command block.  If the application
has connected to an HP ALLBASE/SQL database, HP ALLBASE/4GL issues
implicit HP ALLBASE/SQL BEGIN WORK and COMMIT WORK commands at these
points.

The TRANSACT *UNDO command has no effect on HP TurboIMAGE/iX file
transactions, but is effective for KSAM file transactions and HP
ALLBASE/SQL file transactions.

If HP ALLBASE/4GL executes a TRANSACT *UNDO command after a TRANSACT
*BEGIN command, but before a TRANSACT *END command is encountered, all
file transactions performed since the TRANSACT *BEGIN command are
reversed.  The TRANSACT *UNDO command:

   *   Issues an SQL ROLLBACK WORK command to undo any uncommitted SQL
       transactions,

              - and then

   *   Reverses all KSAM data file transactions that have been performed
       since the TRANSACT *BEGIN command.

              - but

   *   Has no effect on HP TurboIMAGE/iX file transactions.  All recovery
       of HP TurboIMAGE/iX file transactions must be set up manually by
       the HP TurboIMAGE/iX database administrator.

After the TRANSACT *UNDO command, HP ALLBASE/4GL executes the next
command in the logic block containing the TRANSACT *UNDO command.

The TRANSACT *BEGIN, TRANSACT *UNDO, and TRANSACT *END commands do not
need to be in the same logic block.

If HP ALLBASE/4GL encounters two TRANSACT *BEGIN commands without an
intervening TRANSACT *UNDO command or a TRANSACT *END command, all
uncommitted SQL transactions and all KSAM file transactions performed
since the first TRANSACT *BEGIN command are reversed, and a new
transaction block is started.

A user may voluntarily cancel a partially complete transaction by
terminating a data screen before the screen has been committed.  If the
user's action terminates the process containing the TRANSACT *BEGIN
command, the system reverses all file transactions performed since the
last TRANSACT *BEGIN command.

HP ALLBASE/4GL displays messages to inform the user that KSAM file
transactions and/or currently open HP ALLBASE/SQL transactions are being
reversed whenever it executes a TRANSACT *UNDO command.

The TRANSACT *MEMO command is only relevant to HP TurboIMAGE/iX file
transactions, and is used to include comments in an HP TurboIMAGE/iX log
record.  This command has no effect on KSAM or HP ALLBASE/SQL
transactions.  For more information about HP TurboIMAGE/iX log records,
refer to the HP TurboIMAGE/iX Database Management System Reference 
Manual.

File Locking 

The TRANSACT *END and TRANSACT *UNDO commands issue implicit FILE *UNLOCK
commands for KSAM files opened in MODE *UNLOCK. The FILE *UNLOCK command
releases all KSAM file locks belonging to the current process.

Limitations 

The HP ALLBASE/4GL transaction logging system does not record
transactions involving serial data files.  This means that the TRANSACT
*UNDO command does not reverse any serial file transactions that have
occurred since the previous TRANSACT *BEGIN command.  The TRANSACT *UNDO
also does not reverse any HP TurboIMAGE/iX file transactions.

The TRANSACT command only supports single level transactions, and does
not provide savepoints.  For transactions that only use HP ALLBASE/SQL,
you can use the BEGIN WORK, SAVEPOINT, COMMIT WORK and ROLLBACK WORK
commands in SQL logic blocks.  If you do use these commands in SQL logic
blocks, don't use TRANSACT commands in the HP ALLBASE/4GL logic blocks
that call the SQL block.

For transactions that involve more than one of KSAM data files, HP
ALLBASE/SQL tables, and HP TurboIMAGE/iX data sets, the begin and end
records are logged for each data manager used.  If the system fails, or
the user cancels a transaction in the time between the creation of two
transaction end records, inconsistency of the databases may result.  When
the user next signs on to HP ALLBASE/4GL and connects to the data base
environment, any incomplete HP ALLBASE/SQL transaction is rolled back to
ensure logical consistency of the data base.  The KSAM data manager does
not provide this facility, so the KSAM part of a mixed transaction may be
inconsistent with the HP ALLBASE/SQL part of the transaction.  The HP
TurboIMAGE/iX data manager provides a rollback facility, but unless the
HP TurboIMAGE/iX administrator has rolled back the transaction, the HP
TurboIMAGE/iX part of a mixed transaction may also be inconsistent with
the HP TurboIMAGE/iX part of the transaction.

Example 
1 

          .
          .
     3  TRANSACT *BEGIN
          .
     5  IF ... THEN ENTER 10 (error condition)
          .
          .
     8  TRANSACT *END
     9  EXIT 
     10 TRANSACT *UNDO
     11 MESSAGE no_transaction
     12 EXIT 

In this logic block, steps 3 and 8 mark the beginning and end of the
block of interdependent commands.  If an error occurs (step 5), HP
ALLBASE/4GL restores all partially completed transactions (except any
that use HP TurboIMAGE/iX data sets) to their previous state at step 10.
Step 11 displays a developer defined message to the user.

Example 2 

          .
          .
     3  TRANSACT *BEGIN
          .
     5  IF ... THEN ENTER 10 (error condition)
     6  TRANSACT *MEMO This task has been done successfully.
          .
     8  TRANSACT *END
     9  EXIT 
     10 MESSAGE no_transaction
     12 EXIT 

In this logic block, steps 3 and 8 mark the beginning and end of the
block of interdependent commands.  If no error occurs, the message "This 
task has been done successfully." is written to the HP TurboIMAGE/iX
database log record.



MPE/iX 5.0 Documentation