mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 12:19:18 +02:00
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:
parent
3505ba4ee6
commit
206e5eb475
@ -843,8 +843,10 @@ begin
|
|||||||
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_CHAR, buffer, FieldDef.Size+1, @StrLenOrInd);
|
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_CHAR, buffer, FieldDef.Size+1, @StrLenOrInd);
|
||||||
ftSmallint: // mapped to TSmallintField
|
ftSmallint: // mapped to TSmallintField
|
||||||
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SSHORT, buffer, SizeOf(Smallint), @StrLenOrInd);
|
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);
|
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
|
ftLargeint: // mapped to TLargeintField
|
||||||
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SBIGINT, buffer, SizeOf(Largeint), @StrLenOrInd);
|
Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SBIGINT, buffer, SizeOf(Largeint), @StrLenOrInd);
|
||||||
ftFloat,ftCurrency: // mapped to TFloatField
|
ftFloat,ftCurrency: // mapped to TFloatField
|
||||||
@ -1088,7 +1090,7 @@ var
|
|||||||
ColName,TypeName:string;
|
ColName,TypeName:string;
|
||||||
FieldType:TFieldType;
|
FieldType:TFieldType;
|
||||||
FieldSize:word;
|
FieldSize:word;
|
||||||
AutoIncAttr, Updatable, FixedPrecScale, Unsigned: SQLLEN;
|
AutoIncAttr, FixedPrecScale, Unsigned, Updatable: SQLLEN;
|
||||||
begin
|
begin
|
||||||
ODBCCursor:=cursor as TODBCCursor;
|
ODBCCursor:=cursor as TODBCCursor;
|
||||||
|
|
||||||
@ -1195,7 +1197,6 @@ begin
|
|||||||
// only one column per table can have identity attr.
|
// only one column per table can have identity attr.
|
||||||
if (FieldType in [ftInteger,ftLargeInt]) and (AutoIncAttr=SQL_FALSE) then
|
if (FieldType in [ftInteger,ftLargeInt]) and (AutoIncAttr=SQL_FALSE) then
|
||||||
begin
|
begin
|
||||||
AutoIncAttr:=0;
|
|
||||||
ODBCCheckResult(
|
ODBCCheckResult(
|
||||||
SQLColAttribute(ODBCCursor.FSTMTHandle, // statement handle
|
SQLColAttribute(ODBCCursor.FSTMTHandle, // statement handle
|
||||||
i, // column number
|
i, // column number
|
||||||
@ -1208,20 +1209,8 @@ begin
|
|||||||
);
|
);
|
||||||
if (AutoIncAttr=SQL_TRUE) and (FieldType=ftInteger) then
|
if (AutoIncAttr=SQL_TRUE) and (FieldType=ftInteger) then
|
||||||
FieldType:=ftAutoInc;
|
FieldType:=ftAutoInc;
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
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 in [ftFloat] then
|
if FieldType in [ftFloat] then
|
||||||
begin
|
begin
|
||||||
FixedPrecScale:=0;
|
FixedPrecScale:=0;
|
||||||
@ -1250,14 +1239,26 @@ begin
|
|||||||
0,
|
0,
|
||||||
nil,
|
nil,
|
||||||
@Unsigned),
|
@Unsigned),
|
||||||
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get unsigned attribute for column %d.',[i]
|
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get unsigned attribute for column %d.',[i]
|
||||||
);
|
);
|
||||||
if Unsigned=SQL_TRUE then
|
if Unsigned=SQL_TRUE then
|
||||||
case FieldType of
|
case FieldType of
|
||||||
ftSmallint: FieldType:=ftWord;
|
ftSmallint: FieldType:=ftWord;
|
||||||
end;
|
end;
|
||||||
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
|
if FieldType=ftUnknown then // if unknown field type encountered, try finding more specific information about the ODBC SQL DataType
|
||||||
begin
|
begin
|
||||||
SetLength(TypeName,TypeNameDefaultLength); // also garantuees uniqueness
|
SetLength(TypeName,TypeNameDefaultLength); // also garantuees uniqueness
|
||||||
|
Loading…
Reference in New Issue
Block a user