Programming Guide



FINISH

Closes the current transaction manager transaction

int sm_tm_command ("FINISH");

Description

FINISH contains the screen exit processing needed by the transaction manager and is called automatically on screen exit. Therefore, if you use only the default transaction manager transaction on your screen, you do not need to explicitly call this command.

As part of its processing, FINISH closes the current transaction, which has been set with the START or CHANGE commands. In cases where you initiate a transaction by calling the START command, you must also call the FINISH command to close that transaction before closing the transaction's screen. Note that you might need to call the CHANGE command to make the transaction active before closing it with the FINISH command.

The FINISH command is called after the named screen exit function and after the default screen function. After FINISH, the transaction manager data structures for what had been the current transaction no longer exist.

Events

Table 8-20 Request events for FINISH

Request Traversal Typical Processing

TM_FINISH

By table/server view from the root table view. Done both for event functions and the transaction model.

Slice:

TM_FINISH

Table 8-21 Slice event processing for FINISH

Slices Typical Processing

TM_FINISH

Give up the save cursor (if it is in use) and the select cursor for the server view encompassing the current table view (if it is in use). For engines where giving up a cursor involves closing the cursor, the return value is TM_CHECK.

Give up data areas allocated to this transaction, but not areas that are allocated for the transaction model, since there can be other transactions that are still active.

Example

The following procedure closes two additional transactions and then changes back to the main transaction which is assumed to have been active when the procedure is invoked and which is closed on screen exit.

proc close_tran
vars main_tran
	main_tran = sm_tm_pinquire(TM_TRAN_NAME)
	call sm_tm_command("CHANGE tran1")
	call sm_tm_command("FINISH")
	call sm_tm_command("CHANGE tran2")
	call sm_tm_command("FINISH")
	call sm_tm_command("CHANGE :main_tran")
return 0

Also, refer to the START command.