Retrieves the length and number of decimal places for a specified decimal column or parameter.
%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 TDINFBCD (TDPROC, RETCODE, OBJECT_TYPE, OBJECT_NUMBER, BCD_LENGTH, BCD_NUMBER_DECIMAL_PLACES);
(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.
(O) Variable where the result of function execution is returned. Its value is one of the codes listed in Table 3-13.
(I) Object type indicator. Indicates whether the object being queried 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. |
(I) Number of the column or parameter.
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; the leftmost column in a row is number 1.
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; the first parameter is number 1.
(O) Variable where the length of the packed decimal field is returned. When used for Sybase numeric or decimal, this is the precision of the numeric or decimal field.
(O) Variable where the number of decimal places in the packed decimal field is returned.
The RETCODE argument can contain any of the return values listed in Table 3-13.
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_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. |
The following code fragment illustrates a typical use of TDINFBCD. This program uses TDSETBCD to set the number of decimal places in the column to 2; it uses TDINFBCD to check how many decimal places are in the column. 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);
Packed decimal data is supported in PL/1, but not in DB-Library or Client-Library. The TDINFLOG 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.
Numeric and Sybase decimal are both used as Client-Library decimal datatypes.
Although the name of this function implies BCD data,
in PL/1 this function is actually used with packed decimal
data.
A server application uses this function to retrieve length information about a column or parameter containing packed decimal information, and to retrieve information about precision and scale of a column or parameter containing Sybase numeric or decimal information.
If this function is used to query an object that does not contain decimal values, it returns the length, but the BCD_NUMBER_DECIMAL_PLACES argument is ignored.
When used to get information about a column, TDINFBCD must be preceded by a TDESCRIB call for the specified column.
Use this function after TDINFPRM to find precision and scale of a Sybase numeric or decimal parameter.
Related functions