Global variables and XA transactions

In an XA environment, session global variable objects will not change. Session global variables, within an XA transaction, are not available to other sessions joining the transaction.

Introduction

If a global variable is created within a session, then it cannot be used by other sessions until the unit of work has committed. However, the newly created variable can be used within the session that created it before the unit of work is committed. This behavior is consistent with other created objects such as tables.

The length attribute and data type of a global variable does not vary once it is created. Furthermore, the global variable cannot be altered at all (for example, its default value).

The setting of a global variable's value is non-transactional. Hence, an application cannot roll back the setting of the value of a global variable. Note the following:
  • If the creation of a global variable is rolled back then the variable no longer exists.
  • If the drop of a global variable is rolled back, the value of the global variable will be what it was before the drop.
Session global variables can have a default value defined for them. This value is automatically assigned to the variable as soon as it is first referenced in a session.

XA interaction

Session global variables are scoped to a per session level within an XA transaction and are not available to other sessions that join the transaction.

Global variables are non-transactional state objects. Hence, in an XA environment (for both tightly coupled transactions and loosely coupled transactions), global variable objects (both existence and value) will not change at XA_end (nor for other XA APIs, like XA_start, XA_rollback).

Note: In contrast, Db2 has implemented declared global temporary tables as transactional state objects. Hence, when the following XA APIs are executed, declared global temporary tables are dropped.
  • XA_rollback
  • XA_end(SUCCESS)
  • XA_start(NOFLAGS)
  • XA_start(JOIN)