On Sat, 25 Mar 2006, Bram Kuijvenhoven wrote:

> Bram Kuijvenhoven wrote:
> > Michael Van Canneyt wrote:
> >> Looking in the ODBCConnection, I would suppose that the DB2 Timestamp is
> >> translated to SQL_TYPE_UTCDATETIME:
> >>
> >>       SQL_TYPE_UTCDATETIME:FieldType:=ftUnknown;
> >>       SQL_TYPE_UTCTIME:   FieldType:=ftUnknown;
> >
> > I guess that at the moment I wrote that code, I was unsure what to do
> > with the SQL_UTC(DATE)TIME datatypes, so I just mapped it to the unknown
> > data type. I will look at it again - maybe I had some more specific
> > reason, but probably not. Note that I currently have tested
> > ODBCConnection only with the MyODBC and .mdb ODBC drivers.
>
> The lines Michael quotes above are in fact commented out. The reason is that 
> the SQL_TYPE_UTC constants are not in the odbcsql unit. No surprise:
>
>  http://www.google.nl/search?q=SQL_TYPE_UTCDATETIME
>
> yields only 6 hits, the first of which is the MSDN ODBC documentation from 
> which I originally heard about these constants. The unixODBC headers in fact 
> do not mention these field types at all! So I doubt the DB2 driver actually 
> returns a type like that.

Ari is using Windows, so it's not that unlikely...

>
> The error message Arí got is defined in dbconst.pp:
>
>  SUknonwnFieldType =  'Unknown field type : %s';
>
> This is used in the method TFieldDef.CreateField in fields.inc as follows:
>
>  Function TFieldDef.CreateField(AOwner: TComponent): TField;
>
>  Var TheField : TFieldClass;
>
>  begin
>  {$ifdef dsdebug}
>    Writeln ('Creating field '+FNAME);
>  {$endif dsdebug}
>    TheField:=GetFieldClass;
>    if TheField=Nil then
>      DatabaseErrorFmt(SUnknownFieldType,[FName]);
>  ...
>
> This should explain why the error message gives the field name. As an 
> alternative, I can raise an error in the ODBCConn unit when I encounter a 
> ftUnknown - then I can also give the type name (unless is it a custom type 
> perhaps).

I think that would be better: this way we can "see" the limits of the ODBC 
connection...

>
> I'll be right back with a version of odbcconn that tries giving a more 
> meaningful error using the sqlGetTypeInfo API call. Arí can also use this to 
> give us more information, that can help us finding out what is actually going 
> wrong.

Excellent, thanks.

Michael.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to