TDSETLEN

Description

Sets the column length for a variable-length field before sending it to a client.

Syntax

COPY SYGWCOB.
01 TDPROC            PIC S9(9)  USAGE COMP SYNC.
01 RETCODE           PIC S9(9)  USAGE COMP SYNC.
01 COLUMN-NUMBER     PIC S9(9)  USAGE COMP SYNC.
01 NEW-COLUMN-LENGTH PIC S9(9)  USAGE COMP SYNC.
CALL 'TDSETLEN' USING TDPROC, RETCODE, COLUMN-NUMBER,
                NEW-COLUMN-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.

RETCODE

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

COLUMN-NUMBER

(I) The number of the column that is being described. Columns are numbered sequentially; the first column in a row is number 1.

NEW-COLUMN-LENGTH

(I) New length of the column data.

This argument specifies the length of the data that is sent in subsequent TDSNDROW calls. This value must be greater than zero but cannot be greater than the maximum length of the column, as determined by TDESCRIB.

Returns

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

Table 3-30: TDSETLEN return values

Return value

Meaning

TDS-OK (0)

Function completed successfully.

TDS-CONNECTION-TERMINATED (-4997)

Connection closed. The remote partner closed (deallocated) the client/server connection.

TDS-ENTRY-NOT-FOUND (-8)

The specified column number, transaction number, or parameter does not exist.

TDS-INVALID-DATA-TYPE (-171)

Illegal datatype. A Sybase datatype supplied in the call is not supported and the conversion cannot be done. The operation failed.

TDS-INVALID-LENGTH (-173)

Wrong length. The length specified in the NEW-COLUMN-LENGTH argument is too long.

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.

Examples

Example 1

The following code fragment illustrates a typical use of TDSETLEN.

*---------------------------------------------------------------- 
  FETCH-AND-SEND-ROWS. 
*---------------------------------------------------------------- 
      EXEC SQL FETCH ECURSOR INTO :EMPLOYEE-FIELDS 
      END-EXEC.
     IF SQLCODE = 0 THEN 
*    -------------------------------------------------------- 
*    Convert from DB2 decimal type (TDS-PACKED-DECIMAL) to 
*    DB-Library MONEY. 
*    -------------------------------------------------------- 
      MOVE LENGTH OF EMPLOYEE-SAL     TO WRKLEN1 
      MOVE LENGTH OF WRK-EMPLOYEE-SAL TO WRKLEN2 
      CALL 'TDCONVRT' USING 			 	 GWL-PROC, GWL-RC, 
	 GWL-CONVRT-SCALE, 
	TDS-PACKED-DECIMAL,
	 WRKLEN1, EMPLOYEE-SAL, TDSMONEY, 
	WRKLEN2, WRK-EMPLOYEE-SAL
*    -------------------------------------------------------- 
*    Do not send trailing blanks of EMPLOYEE-LNM. 
*    -------------------------------------------------------- 
      MOVE LENGTH OF EMPLOYEE-LNM TO WRKLEN1 
      MOVE 2                      TO CTR-COLUMN
     PERFORM VARYING WRK-BLANKS-SS FROM 1 BY 1 
            UNTIL WRK-BLANKS-SS > WRKLEN1 
            OR EMPLOYEE-LNM-CHARS(WRK-BLANKS-SS) <= SPACE 
      END-PERFORM
     IF WRK-BLANKS-SS < WRKLEN1 THEN 
            SUBTRACT 1 FROM WRK-BLANKS-SS 
            CALL 'TDSETLEN' USING GWL-PROC, GWL-RC, CTR-COLUMN,
                                    WRK-BLANKS-SS 
      END-IF 
*          ------------------------------------------------------
*          Send a row to the client. 
*          ------------------------------------------------------
            CALL 'TDSNDROW' USING GWL-PROC, GWL-RC 
            ADD 1 TO PARM-RETURN-ROWS 
           IF GWL-RC = TDS-CANCEL-RECEIVED THEN 
                MOVE 'Y' TO ALL-DONE-SW 
            END-IF
     ELSE IF SQLCODE = +100 THEN 
            MOVE 'Y' TO ALL-DONE-SW
     ELSE IF SQLCODE < 0 THEN 
            MOVE 'Y' TO ALL-DONE-SW 
            PERFORM FETCH-ERROR 
      END-IF.

Usage

See also

Related functions