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;

As you can see, they are not recignized by the ODBC connection.

Or, Arí has an older odbcconn, where SQL_TIMESTAMP was mapped to ftTimeStamp, 
which in turn has no FieldClass associated with it, giving, on closer 
inspection, the same error -- 'Unknown field type'!.

Some more details:
 TFieldDef.CreateField calls GetFieldClass and raises the error when this 
method returns nil.
 TFieldDef.GetFieldClass in turn calls the GetFieldClass of the associated 
dataset.
 The only implementatoin of GetFieldClass is TDataset.GetFieldClass (grep -ir 
is your friend here), which simply uses the DefaultFieldClass array const.
 DefaultFieldClass does map ftTimeStamp to nil, causing the 'Unknown field 
type' error to occur with SQL_TIMESTAMPs in odbcconn units before revision 1980.
 See 
http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/fcl/db/sqldb/odbc/odbcconn.pas?rev=1980&r1=1710&r2=1980.

Anyway, the patch I sent can still be applied to svn :)

Note that the odbcconn unit supports all data types except SQL_GUID, 
SQL_INTERVAL_* and the strange SQL_UTC* types, along with custom types specific 
to certain DBMSes. If someone encounters problems with this, I might implement 
an option like 'ConvertUnknownDataTypesToString'.

Note that the SQL_INTERVAL_* data types seem to have no corresponding field 
types in the db unit... any hints on this are appreciated! ftGuid also has no 
corresponding field class it seems.

Also, if someone wants to have real transaction support for ODBC, I will try to 
implement it. I did not need it for the application I wrote the initial 
odbcconn for, but I'm not unwilling to improve the unit for others! Of course 
other people can also make patches adding/fixing features.

Regards,

Bram

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

Reply via email to