In this section: |
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:
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 adapter settings:
connection |--------------------------------------------------------->| |------LUW----->|--- LUW ------>| |--- LUW ----->| F | . . . . . . F O C U S . . . s e s s i o n . . . . . . . . . . I N | | | | | cmd user cmd cmd cmd beg COMMIT end beg end |--------- MODIFY ------------->| |----TABLE --->| (a) (b) (c) (d) (e) (f) (g) AUTOCOMMIT ON COMMAND AUTOCLOSE ON FIN AUTODISCONNECT ON FIN |
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 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 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 adapter does not automatically issue any COMMIT, CLOSE, or DISCONNECT command until after the FIN at the end of the FOCUS session:
Note: The Adapter for Teradata does not support this type of session.
connection |------------------------------------------------------------->| |----------LUW------------------------>| |--LUW-->| F | . . . . . . F O C U S . . . s e s s i o n . . . . . . . . . . . . I N | | | | | | | cmd cmd cmd cmd user cmd cmd beg end beg end COMMIT beg end |----TABLE--->| |-PASSTHRU->| |MODIFY >| (a) (b) (c) (d) (e) (f) (g) (h) (i) AUTOCOMMIT ON FIN AUTOCLOSE ON FIN AUTODISCONNECT ON FIN |
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 Adapter for Teradata does not support this type of session.
|--connection--->|--connection->|-conn-->|--connection-->|| |--LUW---------->|--LUW-------->|-LUW--->|--LUW--------->| F | . . . . . . F O C U S . . . s e s s i o n . . . . . . . . . . . . I N | | | | | cmd CRTFORM user CRTFORM cmd beg COMMIT end |---------------------MODIFY---------------------------->| (a) (b) (c) (d) (e) (f) (g) AUTOCOMMIT ON CRTFORM AUTOCLOSE ON COMMIT AUTODISCONNECT ON COMMIT |
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 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 adapter generates a COMMIT.
Note: For DB2, a thread is opened when the connection is established and closed when the connection is severed.
The following example demonstrates how to explicitly control the scope of an LUW using the 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 |