TDSTATUS

Description

Retrieves the last status information received from a remote procedure call (RPC) or SQL command string.

Syntax

% INCLUDE SYGWPLI;
01 TDPROC               PTR,
01 RETCODE              FIXED BIN(31),
01 RETURN_STATUS_NUMBER FIXED BIN(31),
01 DONE_STATUS          FIXED BIN(31),
01 DONE_COUNT           FIXED BIN(31),
01 COMM_STATE           FIXED BIN(31),
01 COMM_RETCODE         FIXED BIN(31),
01 COMM_ERROR_SUBCODE   FIXED BIN(31);
CALL TDSTATUS	(TDPROC, RETCODE, RETURN_STATUS_NUMBER,
	 DONE_STATUS, DONE_COUNT, COMM_STATE,
	 COMM_RETCODE, COMM_ERROR_SUBCODE);

Parameters

TDPROC

(I) Handle for this client/server connection. This must be the same value specified in the associated TDACCEPT call. The TDPROC handle corresponds to the connection and command handles in Open Client Client-Library.

RETCODE

(O) Variable where the result of function execution is returned. Its value is one of the codes listed in Table 3-43.

RETURN_STATUS_NUMBER

(O) Variable where the completion code for this request is stored. This code is an integer that indicates normal completion, an error, or other condition. Negative numbers (-1 to -99) and zero are Sybase-defined return status numbers. Positive numbers are user-defined values. For a list of Sybase-defined return status numbers, see the discussion of TDSNDDON.

DONE_STATUS

(O) Variable where the result of the operation is stored. This value indicates whether the operation completed normally or returned an error, and whether any rows were affected. DONE_STATUS returns one of the following values:

TDS_DONE_FINAL (0x0000)

The set of results currently being sent is the final set of results.

TDS_DONE_CONTINUE (0x0001)

More results follow. This option tells the receiving program to continue retrieving results until this argument specifies TDS_DONE_FINAL or TDS_DONE_ERROR.

TDS_DONE_ERROR (0x0002)

The last request received from the client resulted in an error.

TDS_DONE_COUNT (0x0010)

The ROW_COUNT argument contains a valid count value.

DONE_COUNT

(O) Variable where the row count for the operation is stored. If the DONE_STATUS indicates that a valid number of rows was affected by the operation, this value indicates how many rows were affected.

COMM_STATE

(O) Variable where the current communication state of the mainframe server is stored. COMM_STATE returns one of the following values:

TDS_RESET (0)

Client/server conversation for this transaction ended. If the current transaction is running under CICS or uses the IMS TM explicit API, the transaction should exit as soon as possible. If the current transaction is a WFI transaction using the IMS TM implicit API, the transaction can accept another client request by calling TDGETREQ.

TDS_SEND (1)

Transaction is in SEND state.

TDS_RECEIVE (2)

Transaction is in RECEIVE state.

TDINFRPC also returns this information.

See “Communication states” for an explanation of communication states.

COMM_RETCODE

(O) Variable where the TDPROC current communication I/O return code is stored. This value is in SAA format.

COMM_ERROR_SUBCODE

(O) Detailed error information. Provides additional information about the cause of failure when TDSTATUS returns a return code other than TDS_OK.

Returns

The RETCODE argument can contain any of the return values listed in Table 3-43.

Table 3-43: TDSTATUS return values

Return value

Meaning

TDS_OK (0)

Function completed successfully.

TDS_CANCEL_RECEIVED (-12)

Operation canceled. The remote partner issued a cancel. The current operation failed.

TDS_INVALID_PARAMETER (-4)

Invalid parameter value. The value assigned to one or more of the arguments supplied in the call is not valid. The operation failed.

TDS_INVALID_TDPROC (-18)

Error in specifying a value for the TDPROC argument.

TDS_STATUS_NOT_RECEIVED (-11)

No status returned from client. No RETURN_STATUS_NUMBER is available because the server did not yet send the status back to the client.

Examples

Example 1

The following code fragment illustrates the use of TDSTATUS to check the communication state before sending a message. This example is taken from the sample program in Appendix B, “Sample RPC Application for CICS.”

	/*------------------------------------------------------------------*/
	SEND_ERROR_MESSAGE: PROC;
	/*------------------------------------------------------------------*/
          SEND_DONE    = SEND_DONE_ERROR;
          MSG_SEVERITY = MSG_SEVERITY_ERROR;
          MSG_NR       = MSG_NR_ERROR;
          MSG_TYPE     = TDS_ERROR_MSG;
          CALL SEND_MESSAGE;
 
          RETURN;
 
  END SEND_ERROR_MESSAGE;
	/*------------------------------------------------------------------*/
	SEND_MESSAGE: PROC;
  	/*------------------------------------------------------------------*/
 
  	/*      ------------------------------------------------------------*/
  	/*      ensure we're in right state to send a message               */
  	/*      ------------------------------------------------------------*/
          CALL TDSTATUS (GWL_PROC, GWL_RC,
                         GWL_STATUS_NR,
                         GWL_STATUS_DONE,
                         GWL_STATUS_COUNT,
                         GWL_STATUS_COMM,
                         GWL_STATUS_RETURN_CODE,
                         GWL_STATUS_SUBCODE);
 
          IF GWL_RC = TDS_OK THEN
          DO;
              IF GWL_STATUS_COMM = TDS_RECEIVE THEN
 
              CALL TDSNDMSG (GWL_PROC, GWL_RC,
                             MSG_TYPE, MSG_NR,
                             MSG_SEVERITY,
                             TDS_ZERO,
                             TDS_ZERO,
                             MSG_RPC, MSG_RPC_L,
                             MSG_TEXT, MSG_TEXT_L);
          END;
          RETURN;
  END SEND_MESSAGE;
  

Usage


TDSTATUS

This function returns the TDS status number, status flags, count, and communication state associated with the current RPC or SQL command batch execution.

See also

Related functions

Related topics

Related documents