DB2® for Linux, UNIX, and Windows supports the XA91 specification defined in X/Open CAE Specification Distributed Transaction Processing: The XA Specification, with the following exceptions:
The XA specification allows the interface to use asynchronous services, so that the result of a request can be checked at a later time. The database manager requires that the requests be invoked in synchronous mode.
The DB2 product does not support transaction migration between threads of control.
As required by the XA interface, the database manager provides a db2xa_switch_std and a db2xa_switch_static_std external C variable of type xa_switch_t to return the XA switch structure to the TM. Other than the addresses of various XA functions, the following fields are returned:
Explicitly states that the DB2 product uses dynamic registration, and that the TM should not use association migration. Implicitly states that asynchronous operation is not supported.
For db2xa_switch_static_std TMNOMIGRATE is set
Explicitly states that the DB2 product uses static registration, and that the TM should not use association migration. Implicitly states that asynchronous operation is not supported.
The XA architecture requires that a Resource Manager (RM) provide a switch that gives the XA Transaction Manager (TM) access to the RM's xa_ routines. An RM switch uses a structure called xa_switch_t. The switch contains the RM's name, non-NULL pointers to the RM's XA entry points, a flag, and a version number.
The switch for DB2 for Linux, UNIX, and Windows can be obtained through either of the following two ways:
#define db2xa_switch_std (*db2xa_switch_std)
#define db2xa_switch_static_std (*db2xa_switch_std)
prior
to using db2xa_switch_std or db2xa_switch_static_std. struct xa_switch_t * SQL_API_FN db2xacic_std( )
struct xa_switch_t * SQL_API_FN db2xacicst_std( )
With either method, you must link your application with libdb2.
The pointer to the xa_switch structure, db2xa_switch_std, or db2xa_switch_static_std is exported as DLL data. This implies that a Windows application using this structure must reference it in one of three ways:
#define db2xa_switch_std (*db2xa_switch_std)
#define db2xa_switch_static_std (*db2xa_switch_std)
prior
to using db2xa_switch_std or db2xa_switch_static_std. extern __declspec(dllimport) struct xa_switch_t db2xa_switch_std
extern __declspec(dllimport) struct xa_switch_t db2xa_switch_static_std
struct xa_switch_t * SQL_API_FN db2xacic_std( )
struct xa_switch_t * SQL_API_FN db2xacicst_std( )
With any of these methods, you must link your application with db2api.lib.
The following code illustrates the different ways in which the db2xa_switch_std or db2xa_switch_static_std can be accessed via a C program. Be sure to link your application with the appropriate library.
#include <stdio.h>
#include <xa.h>
struct xa_switch_t * SQL_API_FN db2xacic_std( );
#ifdef DECLSPEC_DEFN
extern __declspec(dllimport) struct xa_switch_t db2xa_switch_std;
#else
#define db2xa_switch_std (*db2xa_switch_std)
extern struct xa_switch_t db2xa_switch_std;
#endif
main( )
{
struct xa_switch_t *foo;
printf ( "switch_std.name );
foo = db2xacic_std();
printf ( "name );
return ;
}