HP 3000 Manuals

HP ALLBASE/SQL Transaction Management [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Reference Manual Vol. 1

HP ALLBASE/SQL Transaction Management 

HP ALLBASE/SQL requires an explicit COMMIT WORK command to terminate any
transaction and make the transaction permanent in the database.  If you
don't commit a transaction, HP ALLBASE/SQL automatically rolls back the
transaction.

If a transaction is not already open, HP ALLBASE/SQL automatically issues
a BEGIN WORK RR command when you execute most HP ALLBASE/SQL commands.
HP ALLBASE/SQL does not issue COMMIT WORK commands automatically.  You
must always commit a transaction explicitly.

You can use the SQL commands BEGIN WORK, COMMIT WORK, and ROLLBACK WORK
in SQL logic blocks to control SQL transactions.

TRANSACT Command 

The HP ALLBASE/4GL TRANSACT command and the SQL BEGIN WORK, COMMIT WORK,
and ROLLBACK WORK commands are interchangeable.  The following table
summarizes the equivalence:

BEGIN WORK [RR]                    <==>     TRANSACT *BEGIN

BEGIN WORK CS                      <==>     No TRANSACT equivalent

COMMIT WORK                        <==>     TRANSACT *END

ROLLBACK WORK                      <==>     TRANSACT *UNDO

The equivalent commands execute the same code.  However, the TRANSACT
command can only be used in HP ALLBASE/4GL logic blocks while the SQL
commands can only be used in SQL logic blocks.

Table Locking 

All access to HP ALLBASE/SQL tables is subject to the normal HP
ALLBASE/SQL locking systems.  Table locking is controlled by the table
locking mode, the LOCK TABLE command, and the options used with the BEGIN
WORK command.  The following paragraphs provide a brief overview of these
items.  For further information on table locking, refer to the HP 
ALLBASE/SQL Reference Manual.

The Table Locking Mode.     

When you define an HP ALLBASE/SQL base table you specify the default
locking mode to be used for all accesses to the table.  This can be one
of three values:

   *   Public.    Allows multiple read access and multiple write access.

   *   Publicread.    Allows multiple read access, but requires exclusive
       access for writing.

   *   Private.    Requires exclusive access for reading or writing.

A Public table allows the highest amount of concurrency.

The LOCK TABLE Command.     

You can use the SQL LOCK TABLE command within an SQL logic block to
override the default table locking mode.  This command allows you to
obtain a lock on an entire table before you begin manipulating the table.

Typically, you would use a LOCK TABLE when you know that a transaction is
going to access a large portion of the table.  By locking the table
before you start the transaction, you reduce the possibility of
encountering a deadlock part way through the transaction.  Locking the
table also removes the overhead involved in obtaining individual locks
for the actions performed within the trans



MPE/iX 5.0 Documentation