Skip to Content.
Sympa Menu

freetds - RE: Strange conversion

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'TDS Development Group'" <freetds AT franklin.oit.unc.edu>
  • Subject: RE: Strange conversion
  • Date: Mon, 5 Aug 2002 12:49:42 +0100


Freddy,

Indeed it appears that "server side" conversions using convert(), are NOT
the same as client side conversions using cs_convert() !

in isql (open client 11 using ct-lib), "select convert(int, '- 13 ')"
returns -13 , as in your example.

However if I write a bespoke program to select '- 13 ' into a character
variable, and then try to convert it to an int using cs_convert(), I get the
following:

CS-Library error: LAYER = (2) ORIGIN = (4) SEVERITY = (1) NUMBER = (24)
cs_convert: cslib user api layer: common library error: The
conversion/operation was stopped due to a syntax error in the source field.

Now, OUR convert_code, when converting a char to int type, just does an
"atoi". We don't try and trap any error returned from atoi, nor do any
"parsing" of the field to make sure it represents a valid value.
I've tried capturing the value of "errno" after passing atoi an invalid
value, with little success. On SUN at least , this doesn't seem to work as
the man pages suggest...

I think we'd have to actually parse the input data - stripping out
whitespace and making sure the remaining characters make sense (optional
leading sign, remainder all numeric ).

HTH,

Bill






Archive powered by MHonArc 2.6.24.

Top of Page