I'm trying to query against Sybase ASE 15 using ODBC. A couple of the columns in the table have user-defined types that ultimately map to datetime, though the types have different definitions. When queried, ODBC indicates that both are SQL_TYPE_TIMESTAMP, so my program binds both as SQL_C_TYPE_TIMESTAMP. This works for one of the columns, but Sybase fills the other one in with a stringified date, instead. Needless to say, the result is a timestamp struct filled with gibberish.

The two user types, plus a dependent definition:

Type_name Storage_type Length Prec Scale Nulls Default_name Rule_name Access_Rule_name Identity
VDT_DATETIME datetime 8 NULL NULL 1 <null> <null> <null> 0

Type_name Storage_type Length Prec Scale Nulls Default_name Rule_name Access_Rule_name Identity
VDT_DATETIMESTAMP datetime 8 NULL NULL 0 VDT_DATETIME_DEF <null> <null> 0

Name Owner Object_type Create_date
VDT_DATETIME_DEF dbo default Apr 29 2003 12:37PM

The VDT_DATETIMESTAMP is the type that works. The other one, VDT_DATETIME, only works if you explicitly CONVERT it to datetime. Otherwise, as I said, it returns a string, but lies and says that it's a timestamp.

I looked for some way that my program could know to bind the two differently, not wanting to add some hack (which I could probably get to work).

I'm not sure why have Default_name set makes one of these work, and not the other. Can anyone shed light on this?

Thanks,

James.