You can establish the following three types of FOCUS sessions by varying the combinations of SET AUTOaction ON event commands. Each is illustrated in a subsequent section:
|
In this section: The Default Data Adapter Session The Pseudo-Conversational Session Example: |
Note:
Teradata implicitly commits each SQL statement individually unless they are enclosed in BEGIN TRANSACTION and END TRANSACTION statements.
The following illustration shows the duration of connections, threads, and Logical Units of Work (LUWs) using the default data adapter settings:
|
The FOCUS session begins at point (a) and ends at point (g), with the FIN command. The connection is established at point (b), the first MODIFY call to the RDBMS, and is retained for the entire FOCUS session.
The LUW initiated at point (b) by the MODIFY is terminated by the explicit COMMIT issued at point (c) within the MODIFY. Point (c) also marks the start of the next LUW which is retained until the end of the MODIFY command at point (d), where the data adapter automatically generates a COMMIT.
A third LUW begins for the TABLE request. It is terminated by the COMMIT automatically generated at the end of the TABLE command. At FIN, the data adapter terminates the connection to the RDBMS. No COMMIT is generated at FIN.
Note: For DB2, the thread is opened when the connection is established and closed when the connection is severed.
The following illustration shows a session in which the user controls the duration of each Logical Unit of Work (LUW). The data adapter does not automatically issue any COMMIT, CLOSE, or DISCONNECT command until after the FIN at the end of the FOCUS session:
Note: The Teradata Data Adapter does not support this type of session.
|
The FOCUS session begins at point (a) and ends at point (i) with the FIN command.
The connection is established by the TABLE command at point (b) and retained until FIN. The LUW also starts at point (b). It is completed at point (f) when the user issues COMMIT WORK as an SQL Passthru request.
The final LUW, triggered by the MODIFY procedure, is not terminated until FIN since there is no other user-issued COMMIT.
Note: For DB2, the thread is opened when the connection is established and closed when the connection is severed.
The next illustration shows how connections can be dropped and re-established within a MODIFY procedure. The AUTOCOMMIT ON CRTFORM, issued within the MODIFY, automatically generates a COMMIT whenever a CRTFORM is displayed.
Note: The Teradata Data Adapter does not support this type of session.
|
The FOCUS session begins at point (a) and ends at point (g) with the FIN command.
The connection and Logical Unit of Work (LUW) are established at point (b), the beginning of the MODIFY procedure. The first CRTFORM triggers a COMMIT, terminating the LUW and connection. The data adapter automatically re-establishes them at the next call to the RDBMS, and they are terminated by the user-issued COMMIT at point (d).
The process is repeated two more times. At the end of the MODIFY procedure, point (f), AUTOCOMMIT reverts to its previous (default) COMMAND setting, and the data adapter generates a COMMIT.
Note: For DB2, a thread is opened when the connection is established and closed when the connection is severed.
In prior releases, the data adapter automatically followed each native SQL request with a COMMIT; therefore, you could not have more than one native SQL command in a single LUW.
The following example demonstrates how to explicitly control the scope of an LUW using the expanded AUTO command settings. Numbers to the left refer to explanatory notes that follow the example.
Dialogue Manager control statements govern COMMIT or ROLLBACK processing based on the &RETCODE value. The example treats any value other than 0 as a failure:
-TOP
SQL DB2 SET AUTODISCONNECT ON FIN
SQL DB2 SET AUTOCLOSE ON FIN
1. SQL DB2 SET AUTOCOMMIT ON FIN
2. SQL DB2 LOCK TABLE XYZ IN EXCLUSIVE MODE
END
3. -IF &RETCODE NE 0 GOTO ROLLBACK ;
4. SQL DB2 INSERT INTO XYZ VALUES ('A','B','C','D') ;
END
-IF &RETCODE NE 0 GOTO ROLLBACK ;
SQL DB2 INSERT INTO XYZ VALUES ('E','F','G','H') ;
END
-IF &RETCODE NE 0 GOTO ROLLBACK ;
SQL DB2 INSERT INTO XYZ VALUES ('I','J','K','L') ;
END
-IF &RETCODE NE 0 GOTO ROLLBACK ;
5. SQL DB2 COMMIT WORK;
END
-IF &RETCODE NE 0 GOTO ROLLBACK ;
-GOTO OUT
-ROLLBACK
SQL DB2 ROLLBACK WORK;
END
-OUT
6. SQL DB2 SET AUTOCOMMIT ON COMMAND
Note:
Information Builders |