TDSETBCD

Description

Sets the length and number of decimal places for a given packed decimal column or parameter. You can also set the number of decimal places for numeric and Sybase decimal columns.

Syntax

% INCLUDE SYGWPLI;
01 TDPROC                    PTR,
01 RETCODE                   FIXED BIN(31),
01 OBJECT_TYPE               FIXED BIN(31),
01 OBJECT_NUMBER             FIXED BIN(31),
01 BCD_LENGTH                FIXED BIN(31),
01 BCD_NUMBER_DECIMAL_PLACES FIXED BIN(31);
CALL TDSETBCD	(TDPROC, RETCODE, OBJECT_TYPE, 
	 OBJECT_NUMBER, BCD_LENGTH, 
                 BCD_NUMBER_DECIMAL_PLACES);

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-29.

OBJECT_TYPE

(I) Object type indicator. Indicates whether the object is a parameter or a column. Assign this argument one of the following values:

TDS_OBJECT_COL(1)

Object is a column in a return row.

TDS_OBJECT_PARM (2)

Object is a parameter.

OBJECT_NUMBER

(I) Number of the column or parameter with the information that is being set.

If the object is a column, this is the position of the column in the row, counting from left to right. Columns are numbered sequentially with the leftmost column in a row number one.

If the object is a return parameter, this is the number of the parameter with the value that is being checked. All parameters are counted, whether or not they are return parameters. Parameters are numbered sequentially with the first parameter number one.

BCD_LENGTH

(I) The length of the packed decimal field. This value must not be a negative number. The maximum allowed length for a packed decimal object is 31. Instead of a specific value, you can default to the COLUMN_MAXLEN specified in the TDESCRIB call that describes this column. To do this, assign this argument a value of TDS_DEFAULT_LENGTH.

BCD_NUMBER_DECIMAL_PLACES

(I) Number of decimal places in the object. This value must not be a negative number. The maximum number of decimal places allowed for a packed decimal object is 31. The maximum decimal places allowed for Sybase numeric or decimal is 77.

Returns

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

Table 3-29: TSETBCD 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_LENGTH (-173)

Wrong length. The length specified in the BCD_LENGTH argument is wrong.

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 TDSETBCD. This example is taken from the sample program in Appendix B, “Sample RPC Application for CICS.”

	/*      ----------------------------------------------------------*/
	/*      Here we let TDESCRIB convert from TDSDECIMAL to TDSFLT8.  */
	/*      --------------------------------------------------------- */
          DB_DESCRIBE_HV_PTR    = ADDR(EMPLOYEE_JC);
          DB_COLUMN_NAME_HV_PTR = ADDR(CN_JC);
          WRKLEN1               = STG(EMPLOYEE_JC);
          WRKLEN2               = STG(CN_JC);
          DB_HOST_TYPE          = TDSDECIMAL;
          DB_CLIENT_TYPE        = TDSFLT8;
          CALL DESCRIBE_COLUMN;
  /*      ------------------------------------------------------------*/
  /*      We must inform the Server Library how many decimal places   */
  /*      are in the EMPLOYEE_JC column.                              */
  /*      ------------------------------------------------------------*/
          CALL TDSETBCD (GWL_PROC, GWL_RC,
                         TDS_OBJECT_COL,
                         CTR_COLUMN,
                         TDS_DEFAULT_LENGTH,
                         GWL_SETBCD_SCALE);
  /*      ------------------------------------------------------------*/
  /*      Demonstrate getting decimal column information.             */
  /*      ------------------------------------------------------------*/
          CALL TDINFBCD (GWL_PROC, GWL_RC,
                         TDS_OBJECT_COL,
                         CTR_COLUMN,
                         GWL_INFBCD_LENGTH,
                         GWL_INFBCD_SCALE);

Usage


TDSETBCD

Packed decimal data is supported in PL/1, but not in DB-Library or Client-Library. This function preserves the scale and value when converting a DB-Library or Client-Library decimal value to PL/1 packed decimal data and vice versa.

NoteAlthough the name of this function implies BCD data, in PL/1 this function is actually used with packed decimal data.

NoteWhen reading in decimal data, call TDSETBCD before calling TDRCVPRM to set the decimal point location. When returning decimal data to a client, call TDSETBCD after calling TDESCRIB.

See also

Related functions