fcl-db: odbc: map ftWord fields to TWordField (avoid potential problem with Big Endian systems)

git-svn-id: trunk@25035 -
This commit is contained in:
lacak 2013-07-04 06:46:45 +00:00
parent 3505ba4ee6
commit 206e5eb475

View File

@ -843,8 +843,10 @@ begin
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_CHAR, buffer, FieldDef.Size+1, @StrLenOrInd);
ftSmallint: // mapped to TSmallintField
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SSHORT, buffer, SizeOf(Smallint), @StrLenOrInd);
ftInteger,ftWord,ftAutoInc: // mapped to TLongintField
ftInteger,ftAutoInc: // mapped to TLongintField
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SLONG, buffer, SizeOf(Longint), @StrLenOrInd);
ftWord: // mapped to TWordField
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_USHORT, buffer, SizeOf(Word), @StrLenOrInd);
ftLargeint: // mapped to TLargeintField
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SBIGINT, buffer, SizeOf(Largeint), @StrLenOrInd);
ftFloat,ftCurrency: // mapped to TFloatField
@ -1088,7 +1090,7 @@ var
ColName,TypeName:string;
FieldType:TFieldType;
FieldSize:word;
AutoIncAttr, Updatable, FixedPrecScale, Unsigned: SQLLEN;
AutoIncAttr, FixedPrecScale, Unsigned, Updatable: SQLLEN;
begin
ODBCCursor:=cursor as TODBCCursor;
@ -1195,7 +1197,6 @@ begin
// only one column per table can have identity attr.
if (FieldType in [ftInteger,ftLargeInt]) and (AutoIncAttr=SQL_FALSE) then
begin
AutoIncAttr:=0;
ODBCCheckResult(
SQLColAttribute(ODBCCursor.FSTMTHandle, // statement handle
i, // column number
@ -1208,20 +1209,8 @@ begin
);
if (AutoIncAttr=SQL_TRUE) and (FieldType=ftInteger) then
FieldType:=ftAutoInc;
end;
Updatable:=0;
ODBCCheckResult(
SQLColAttribute(ODBCCursor.FSTMTHandle,
i,
SQL_DESC_UPDATABLE,
nil,
0,
nil,
@Updatable),
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get updatable attribute for column %d.',[i]
);
end
else
if FieldType in [ftFloat] then
begin
FixedPrecScale:=0;
@ -1250,14 +1239,26 @@ begin
0,
nil,
@Unsigned),
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get unsigned attribute for column %d.',[i]
);
if Unsigned=SQL_TRUE then
case FieldType of
ftSmallint: FieldType:=ftWord;
end;
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get unsigned attribute for column %d.',[i]
);
if Unsigned=SQL_TRUE then
case FieldType of
ftSmallint: FieldType:=ftWord;
end;
end;
Updatable:=0;
ODBCCheckResult(
SQLColAttribute(ODBCCursor.FSTMTHandle,
i,
SQL_DESC_UPDATABLE,
nil,
0,
nil,
@Updatable),
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get updatable attribute for column %d.',[i]
);
if FieldType=ftUnknown then // if unknown field type encountered, try finding more specific information about the ODBC SQL DataType
begin
SetLength(TypeName,TypeNameDefaultLength); // also garantuees uniqueness