Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

Conversion
[LibTDS API]

\ More...

Functions

int tds_get_conversion_type (int srctype, int colsize)
 Return type suitable for conversions (convert all nullable types to fixed type).

TDS_INT tds_convert (TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
 tds_convert convert a type to another.

TDS_INT tds_get_null_type (int srctype)
 Get same type but nullable.

size_t tds_strftime (char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr)
 format a date string according to an "extended" strftime formatting definition.

unsigned char tds_willconvert (int srctype, int desttype)
 Test if a conversion is possible.

TDS_INT tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr)
 Convert from db date format to a structured date format.


Detailed Description

\


Function Documentation

TDS_INT tds_convert TDSCONTEXT *    tds_ctx,
int    srctype,
const TDS_CHAR *    src,
TDS_UINT    srclen,
int    desttype,
CONV_RESULT *    cr
 

tds_convert convert a type to another.

If you convert to SYBDECIMAL/SYBNUMERIC you MUST initialize precision and scale of cr. Do not expect string to be zero terminated. Databases support zero inside string. Doing strlen on result may result on data loss or even core. Use memcpy to copy destination using length returned. This function do not handle NULL, srclen should be >0, if not undefinited behaviour...

Parameters:
tds_ctx  context (used in conversion to data and to return messages)
srctype  type of source
src  pointer to source data to convert
srclen  length in bytes of source (not counting terminator or strings)
desttype  type of destination
cr  structure to hold result
Returns:
length of result or TDS_CONVERT_* failure code on failure. All TDS_CONVERT_* constants are <0.

TDS_INT tds_datecrack TDS_INT    datetype,
const void *    di,
TDSDATEREC   dr
 

Convert from db date format to a structured date format.

Parameters:
datetype  source date type. SYBDATETIME or SYBDATETIME4
di  source date
dr  destination date
Returns:
TDS_FAIL or TDS_SUCCEED

int tds_get_conversion_type int    srctype,
int    colsize
 

Return type suitable for conversions (convert all nullable types to fixed type).

Parameters:
srctype  type to convert
colsize  size of type
Returns:
type for conversion

TDS_INT tds_get_null_type int    srctype
 

Get same type but nullable.

Parameters:
srctype  type requires
Returns:
nullable type

size_t tds_strftime char *    buf,
size_t    maxsize,
const char *    format,
const TDSDATEREC   dr
 

format a date string according to an "extended" strftime formatting definition.

Parameters:
buf  output buffer
maxsize  size of buffer in bytes (space include terminator)
format  format string similar to strftime. z for milliseconds
dr  date to convert
Returns:
length of string returned, 0 for error

unsigned char tds_willconvert int    srctype,
int    desttype
 

Test if a conversion is possible.

Parameters:
srctype  source type
desttype  destination type
Returns:
0 if not convertible


Generated on Tue Jan 13 20:54:54 2004 for FreeTDS API by doxygen1.2.18