Remote unit of work for distributed relational databases

The remote unit of work facility provides for the remote preparation and execution of SQL statements.

An application process at computer system A can connect to an application server at computer system B and, within one or more units of work, execute any number of static or dynamic SQL statements that reference objects at B. After ending a unit of work at B, the application process can connect to an application server at computer system C, and so on.

Most SQL statements can be remotely prepared and executed, with the following restrictions:
  • All objects referenced in a single SQL statement must be managed by the same application server.
  • All of the SQL statements in a unit of work must be executed by the same application server.

At any given time, an application process is in one of four possible connection states:

  • Connectable and connected

    An application process is connected to an application server, and CONNECT statements can be executed.

    If implicit connect is available:
    • The application process enters this state when a CONNECT TO statement or a CONNECT without operands statement is successfully executed from the connectable and unconnected state.
    • The application process might enter this state from the implicitly connectable state if any SQL statement other than CONNECT RESET, DISCONNECT, SET CONNECTION, or RELEASE is issued.
    Whether or not implicit connect is available, this state is entered when:
    • A CONNECT TO statement is successfully executed from the connectable and unconnected state.
    • A COMMIT or ROLLBACK statement is successfully issued, or a forced rollback occurs from the unconnectable and connected state.
  • Unconnectable and connected

    An application process is connected to an application server, but a CONNECT TO statement cannot be successfully executed to change application servers. The application process enters this state from the connectable and connected state when it executes any SQL statement other than the following: CONNECT TO, CONNECT with no operand, CONNECT RESET, DISCONNECT, SET CONNECTION, RELEASE, COMMIT, or ROLLBACK.

  • Connectable and unconnected

    An application process is not connected to an application server. CONNECT TO is the only SQL statement that can be executed; otherwise, an error (SQLSTATE 08003) is raised.

    Whether or not implicit connect is available, the application process enters this state if an error occurs when a CONNECT TO statement is issued, or an error occurs within a unit of work, causing the loss of a connection and a rollback. An error that occurs because the application process is not in the connectable state, or because the server name is not listed in the local directory, does not cause a transition to this state.

    If implicit connect is not available:
    • The application process is initially in this state
    • The CONNECT RESET and DISCONNECT statements cause a transition to this state.
  • Implicitly connectable (if implicit connect is available).

    If implicit connect is available, this is the initial state of an application process. The CONNECT RESET statement causes a transition to this state. Issuing a COMMIT or ROLLBACK statement in the unconnectable and connected state, followed by a DISCONNECT statement in the connectable and connected state, also results in this state.

Availability of implicit connect is determined by installation options, environment variables, and authentication settings.

It is not an error to execute consecutive CONNECT statements, because CONNECT itself does not remove the application process from the connectable state. It is, however, an error to execute consecutive CONNECT RESET statements. It is also an error to execute any SQL statement other than CONNECT TO, CONNECT RESET, CONNECT with no operand, SET CONNECTION, RELEASE, COMMIT, or ROLLBACK, and then to execute a CONNECT TO statement. To avoid this error, a CONNECT RESET, DISCONNECT (preceded by a COMMIT or ROLLBACK statement), COMMIT, or ROLLBACK statement should be executed before the CONNECT TO statement.

Figure 1. Connection State Transitions If Implicit Connect Is Available
Connection State Transitions If Implicit Connect Is Available
Figure 2. Connection State Transitions If Implicit Connect Is Not Available
Connection State Transitions If Implicit Connect Is Not Available