Previous Topic: Managing Nonshareable TransactionsNext Topic: Effect of Teleprocessing Statements and Events


Sharing Transactions Among Sessions

Sharing a Transaction

A transaction can be shared by multiple database sessions, both SQL sessions and non-SQL sessions (rununits). By sharing a transaction, sessions will not deadlock among themselves even if they access and update the same data.

Enabling Transaction Sharing

An SQL session is eligible to share its transaction if transaction sharing is in effect when the database session is started.

Transaction sharing is in effect for a top-level session if:

For subordinate sessions, transaction sharing is controlled through the TRANSACTION SHARING parameter of the SQL invoked routine's definition unless overridden by a call to IDMSIN01 from within the routine.

Note: For more information about the TRANSACTION SHARING parameter of the CREATE PROCEDURE, CREATE TABLE PROCEDURE or CREATE FUNCTION statements, see the CA IDMS SQL Reference Guide.

Whether transaction sharing is enabled for a remote SQL session is determined by the attribute in effect in the CA IDMS environment in which the session-initiating statement is issued. (A remote session is one that is connected to a dictionary residing on a central version different from where the application is executing.)

Regardless of how transaction sharing is enabled, if it is in effect at the time a database session is started, then that database session is eligible to share its transaction with other database sessions started by the same task or user session. The following rules determine whether two sessions will share a transaction.

Application Programming Considerations

Transaction sharing affects applications in the following ways:

Inter-session Conflicts

Database sessions that share a transaction can impact each other in ways that would not be possible without transaction sharing since locking would prevent such interactions. For example, a record can be deleted by one database session while it is current of another database session that is sharing the same transaction. This can result in new and possibly unexpected error conditions. If a database session's currency is impacted by an update made through another database session, that currency is invalidated. If a subsequent DML request, such as a FETCH from a cursor, relies on that invalidated currency, an error is returned.

Before enabling transaction sharing for an application, you should ensure that affected programs handle these errors appropriately.

Effect of Rollback Requests

If multiple database sessions share a transaction and one of those sessions issues a rollback request, all changes made within the transaction are immediately rolled out. Other sessions sharing the transaction must issue their own rollback requests before issuing any other DML requests. Issuing another DML request instead of a rollback will result in an error:

Effect of Commit Requests

If multiple top level database sessions share a transaction and one of those sessions issues a commit request, no changes are committed until:

The term "commit" refers to any DML command that would normally result in committing changes (COMMIT RELEASE, COMMIT CONTINUE, FINISH, and so forth).

A commit issued through a subordinate session has no impact on its transaction if it is shared since such a transaction can only be committed through the encompassing session.

Unless a COMMIT CONTINUE request is issued (for which currency locks are retained), all currencies owned by the issuing database session are immediately released. However, implicit exclusive locks and explicit locks acquired by the database session remain until the transaction is committed, even if the request terminates the database session.