Programming Guide



sm_tm_command

Executes a transaction command

#include <tmusubs.h>
int sm_tm_command (cmd_string);

Arguments

cmd_string
Contains one of the following transaction commands and its associated parameters. The parameters can include a table view name and/or command scope. Refer to the specific command for details and command syntax.

CHANGE

FORCE_CLOSE

CLEAR

NEW

CLOSE

REFRESH

CONTINUE

RELEASE

CONTINUE_BOTTOM

SAVE

CONTINUE_DOWN

SELECT

CONTINUE_TOP

START

CONTINUE_UP

VIEW

COPY

WALK_DELETE

COPY_FOR_UPDATE

WALK_INSERT

COPY_FOR_VIEW

WALK_SELECT

FETCH

WALK_UPDATE

FINISH


Returns

Description

sm_tm_command executes the specified transaction manager command.

When specifying a command, the table view name is case sensitive; however, the command name and the optional parameters following the table view name are not case sensitive.

By definition, a command is in progress from the moment sm_tm_command is called until the moment it returns. As it processes most commands, sm_tm_command invokes transaction event functions and transaction models. These, in turn, should not invoke transaction manager commands, because the transaction manager cannot process its commands recursively. This implies that they should not close the active screen (which triggers a FINISH command), or cause any other screen to be displayed that contains table views (which triggers a CHANGE command).

Transaction Modes

After recognizing a transaction command, the transaction manager either sets the transaction mode or checks the transaction mode to see if the specified command is available with the current mode. If the command is not supported in the current mode, or if the command is not recognized, then the transaction manager displays an error message that the mode does not permit the specified command. It also sets the value of TM_STATUS to -1, which causes sm_tm_command to return a value of -1. For more information on command availability in transaction modes, refer to "Setting the Transaction Mode" in Application Development Guide.

Tree Traversal

The transaction tree is the group of linked table views that are part of the current transaction manager transaction. After a command is issued, the transaction manager traverses the transaction tree, issuing the request and slice events defined for that command for each table view and performing the processing defined for each event in transaction event functions and transaction models. The most common order is referred to as table/server view order. A server view is defined as:

Tree traversal in table/server view order begins at the root table view or at the specified table view. The traversal covers all table views within the server view, and then moves on to the next server view. The Parent and Child properties for each link help determine the traversal order. The tree traversal reaches a parent table view before its child, but there can be intervening table views (in the same and different server views).

Restriction

A transaction manager transaction must be in progress in order to call commands. Transactions are created with the START command which is called automatically on screen entry. However, the Panther events that occur on screen entry call the unnamed JPL procedure before calling the START command. Therefore, transaction manager commands cannot be invoked in the unnamed procedure.

Example

int sm_tm_command ("SELECT titles BELOW_TV");

Errors

Errors in the transaction manager set TM_STATUS to -1.

In addition, there are return values for transaction models or transaction event functions that set the value of TM_STATUS. Table 8-2 lists the return codes, the events that get generated for each return code, and the processing that occurs for the event.

Table 8-2 Return values for transaction event functions and transaction models

Return Code Event Processing

TM_OK

None

None.

TM_PROCEED

None

Invoke transaction model.

TM_FAILURE

TM_NOTE_FAILURE

Call sm_tm_failure_message.

TM_UNSUPPORTED

TM_NOTE_UNSUPPORTED

Call sm_tm_failure_message.

TM_CHECK

TM_TEST_ERROR

Call sm_tm_dbi_checker.

TM_CHECK_ONE_ROW

TM_TEST_ONE_ROW

Call sm_tm_dbi_checker.

TM_CHECK_SOME_ROWS

TM_TEST_SOME_ROWS

Call sm_tm_dbi_checker.

Events

Once you select a transaction command, the transaction manager generates the transaction events defined for that command. These events are defined to perform the processing needed for the command. The major events for each command are called requests. Some requests are further subdivided into more events, called slices. As the transaction manager traverses the tree, it looks for the processing for each event first in a transaction manager event function, then in an engine-specific transaction model, and then in the common transaction model.

The transaction manager has an event stack, onto which the transaction events are pushed. As the events are processed, they are popped from the stack. For more information on the event stack, refer to Chapter 35, "Generating Transaction Manager Events," in Application Development Guide.

Table 8-3 lists all the transaction manager events. A description of the general processing performed by each request or slice is part of the documentation for a command in which it is used. To see the processing done for a particular database engine, refer to the transaction model for that engine. For a summary list of the commands, requests, and slices, refer to Chapter 9, "Transaction Model Events."

Table 8-3 Events available in the transaction manager

Event Command*

TM_CLEAR

CLEAR

TM_CLEAR_SEL_COUNT_FLAG

SELECT, VIEW

TM_CLOSE

CLOSE

TM_CONTINUE_BOTTOM

CONTINUE_BOTTOM

TM_CONTINUE_DOWN

CONTINUE_DOWN

TM_CONTINUE_TOP

CONTINUE_TOP

TM_CONTINUE_UP

CONTINUE_UP

TM_COPY

COPY

TM_COPY_FOR_UPDATE

COPY_FOR_UPDATE

TM_COPY_FOR_VIEW

COPY_FOR_VIEW

TM_DELETE

SAVE

TM_DELETE_DECLARE

SAVE

TM_DELETE_EXEC

SAVE

TM_DISCARD

CLOSE

TM_FETCH

FETCH

TM_FINISH

FINISH

TM_GET_SAVE_CURSOR

SAVE

TM_GET_SEL_CURSOR

SELECT

TM_GIVE_UP_SAVE_CURSOR

SAVE

TM_GIVE_UP_SEL_CURSOR

SELECT

TM_INSERT

SAVE

TM_INSERT_DECLARE

SAVE

TM_INSERT_EXEC

SAVE

TM_NEW

NEW

TM_NOTE_FAILURE

Part of error processing

TM_NOTE_UNSUPPORTED

Part of error processing

TM_POST_CLEAR

CLEAR

TM_POST_CLOSE

CLOSE

TM_POST_COPY

COPY

TM_POST_COPY_FOR_UPDATE

COPY_FOR_UPDATE

TM_POST_COPY_FOR_VIEW

COPY_FOR_VIEW

TM_POST_NEW

NEW

TM_POST_RELEASE

RELEASE

TM_POST_SAVE

SAVE

TM_POST_SAVE1

SAVE

TM_POST_SAVE2

SAVE

TM_POST_SELECT

SELECT

TM_POST_VAL_LINK

Part of validation link processing

TM_POST_VIEW

VIEW

TM_PRE_CLEAR

CLEAR

TM_PRE_CLOSE

CLOSE

TM_PRE_COPY

COPY

TM_PRE_COPY_FOR_UPDATE

COPY_FOR_UPDATE

TM_PRE_COPY_FOR_VIEW

COPY_FOR_VIEW

TM_PRE_NEW

NEW

TM_PRE_RELEASE

RELEASE

TM_PRE_SAVE

SAVE

TM_PRE_SELECT

SELECT

TM_PRE_VAL_LINK

Part of validation link processing

TM_PRE_VIEW

VIEW

TM_PREPARE_CONTINUE

SELECT, VIEW

TM_QUERY

CLOSE

TM_RELEASE

RELEASE

TM_SAVE

SAVE

TM_SAVE_BEGIN

SAVE

TM_SAVE_COMMIT

SAVE

TM_SAVE_ROLLBACK

SAVE

TM_SAVE_SET_MODE

SAVE

TM_SET_SEL_COUNT_FLAG

SELECT, VIEW

TM_SEL_BUILD_PERFORM

SELECT

TM_SEL_CHECK

FETCH

TM_SEL_COUNT_CHECK

SELECT, VIEW

TM_SEL_GEN

SELECT

TM_SELECT

SELECT

TM_START

START

TM_TEST_ERROR

Part of error processing

TM_TEST_ONE_ROW

Part of error processing

TM_TEST_SOME_ROWS

Part of error processing

TM_UPDATE

SAVE

TM_UPDATE_DECLARE

SAVE

TM_UPDATE_EXEC

SAVE

TM_VAL_BUILD_PERFORM

Part of validation link processing

TM_VAL_CHECK

Part of validation link processing

TM_VAL_GEN

Part of validation link processing

TM_VAL_LINK

Part of validation link processing

TM_VIEW

VIEW

TM_WALK_DELETE

WALK_DELETE

TM_WALK_INSERT

WALK_INSERT

TM_WALK_SELECT

WALK_SELECT

TM_WALK_UPDATE

WALK_UPDATE

* Indicates under which command the event is documented.