Progress
Embedded SQL-92
Guide and Reference
Explicit Data Conversion Using tpe_conv_data( )
To convert data explicitly from one data type to another, use the tpe_conv_data SQL-92 API function. This is the syntax for the tpe_conv_data function:
dtype
Data type of the INPUT buffer being converted. See the list of supported defined data types.
buflen
The length of the INPUT buffer
buf
.buf
A buffer containing the INPUT data and whose type is specified in
dtype
.fmt
A format string that specifies the output format. Valid only if dtype is TPE_DT_DATE and odtype is TPE_DT_CHAR. See Chapter 2, “SQL Language Elements,” in the Progress SQL-92 Guide and Reference for information on date-time format strings.
odtype
Data type of the OUTPUT required after conversion.
obuflen
The length of the OUTPUT buffer obuf.
obuf
The target OUTPUT buffer for the converted data.
dtype
Must be one of the data type symbolic names defined in
$DLC/include/sql_lib.h.
The defined symbolic names include:EXAMPLE
The following code fragment illustrates how to convert CHARACTER data to INTEGER data:
In this example indata[ ] is the buffer containing INPUT data and outval is the buffer where the converted data is returned.
The tpe_conv_data function does perform type conversions between character types and exact or approximate numeric types, unlike the limitation imposed by implicit type conversions.
EXAMPLEThe following code fragment illustrates how to convert NUMERIC Data to CHARACTER data:
This example illustrates using tpe_conv_data( ) to convert NUMERIC data retrieved from the database into character data for use by the host program. In the example var7 is the buffer containing input data and var0 is the target for output data.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |