TDSQLLEN

Description

Determines the length of a language string received from a client.

Syntax

% INCLUDE SYGWPLI;
01 TDPROC     PTR,
01 SQL_LENGTH FIXED BIN(31);
CALL TDSQLLEN  (TDPROC, SQL_LENGTH);

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.

SQL_LENGTH

(O) The length of the incoming language string. For graphic datatypes, this is the number of double-byte characters; for other datatypes, it is the number of bytes.

Returns

This function has no RETCODE argument. It returns the length of the SQL string in the SQL_LENGTH argument. If the value in SQL_LENGTH is -1, call TDRESULT, and examine its return code to determine what the problem is.

Examples

Example 1

The following code fragment illustrates the use of TDSQLLEN to determine the length of the incoming SQL string. This example is taken from the sample program in Appendix C, “Sample Language Application for CICS.”

	/*------------------------------------------------------------------*/
	READ_IN_SQL_TEXT:
	/*------------------------------------------------------------------*/
 
	/*      ------------------------------------------------------------*/
	/*      prepare for receive                                         */
	/*      ------------------------------------------------------------*/
          CALL TDRESULT (GWL_PROC, GWL_RC);
 
	/*      ------------------------------------------------------------*/
	/*      load ptr to redefined sql text                              */
	/*      ------------------------------------------------------------*/
          LANG_BUFFER_PTR = ADDR(LANG_BUFFER_DB2);
 
	/*      ------------------------------------------------------------*/
	/*      get len of language text, ensure not too big for us         */
	/*      (this could be handled without TDSQLLEN by checking         */
	/*      LANG_ACTUAL_LEN doesn't exceed LANG_MAX_L in TDRCVSQL call) */
	/*      ------------------------------------------------------------*/
          CALL TDSQLLEN (GWL_PROC, GWL_SQLLEN);
 
          LANG_MAX_L = STG(LANG_BUFFER_TEXT);
 
          IF GWL_SQLLEN > LANG_MAX_L THEN
          DO;
              MSG_TEXT   = MSG_BAD_LEN;
              MSG_TEXT_L = STG(MSG_BAD_LEN);
              CALL SEND_ERROR_MESSAGE;
              GO TO END_PROGRAM;
          END;
 
  /*      ------------------------------------------------------------*/
  /*      get language text                                           */
  /*      ------------------------------------------------------------*/
          CALL TDRCVSQL (GWL_PROC, GWL_RC,
                         LANG_BUFFER_TEXT,
                         LANG_MAX_L,
                         LANG_ACTUAL_L);
 
          LANG_BUFFER_LL = LANG_ACTUAL_L;

Usage


TDSTATUS

A server application uses this function to determine the actual length of an incoming string.

Related functions