mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 18:25:58 +02:00
odbc: fix passing ANSI parameters with FPC character conversion
git-svn-id: trunk@43698 -
This commit is contained in:
parent
49ba4731ed
commit
a66442ea47
@ -400,6 +400,7 @@ var
|
|||||||
BufferLength, StrLenOrInd: SQLLEN;
|
BufferLength, StrLenOrInd: SQLLEN;
|
||||||
CType, SqlType, DecimalDigits:SQLSMALLINT;
|
CType, SqlType, DecimalDigits:SQLSMALLINT;
|
||||||
APD: SQLHDESC;
|
APD: SQLHDESC;
|
||||||
|
BytesVal: TBytes;
|
||||||
begin
|
begin
|
||||||
// Note: it is assumed that AParams is the same as the one passed to PrepareStatement, in the sense that
|
// Note: it is assumed that AParams is the same as the one passed to PrepareStatement, in the sense that
|
||||||
// the parameters have the same order and names
|
// the parameters have the same order and names
|
||||||
@ -440,43 +441,27 @@ begin
|
|||||||
SqlType:=SQL_BIGINT;
|
SqlType:=SQL_BIGINT;
|
||||||
ColumnSize:=19;
|
ColumnSize:=19;
|
||||||
end;
|
end;
|
||||||
ftString, ftFixedChar, ftBlob, ftMemo, ftGuid,
|
ftBlob, ftBytes, ftVarBytes:
|
||||||
ftBytes, ftVarBytes:
|
|
||||||
begin
|
begin
|
||||||
StrVal:=AParams[ParamIndex].AsString;
|
BytesVal:=AParams[ParamIndex].AsBytes;
|
||||||
StrLenOrInd:=Length(StrVal);
|
StrLenOrInd:=Length(BytesVal);
|
||||||
if StrVal='' then //HY104
|
if Length(BytesVal)=0 then //HY104
|
||||||
begin
|
begin
|
||||||
StrVal:=#0;
|
BytesVal:=[0];
|
||||||
StrLenOrInd:=SQL_NTS;
|
StrLenOrInd:=SQL_NTS;
|
||||||
end;
|
end;
|
||||||
PVal:=@StrVal[1];
|
PVal:=@BytesVal[0];
|
||||||
Size:=Length(StrVal);
|
Size:=Length(BytesVal);
|
||||||
ColumnSize:=Size;
|
ColumnSize:=Size;
|
||||||
BufferLength:=Size;
|
BufferLength:=Size;
|
||||||
|
CType:=SQL_C_BINARY;
|
||||||
case AParams[ParamIndex].DataType of
|
case AParams[ParamIndex].DataType of
|
||||||
ftBytes, ftVarBytes:
|
ftBytes, ftVarBytes: SqlType:=SQL_VARBINARY;
|
||||||
begin
|
else // ftBlob
|
||||||
CType:=SQL_C_BINARY;
|
|
||||||
SqlType:=SQL_VARBINARY;
|
|
||||||
end;
|
|
||||||
ftBlob:
|
|
||||||
begin
|
|
||||||
CType:=SQL_C_BINARY;
|
|
||||||
SqlType:=SQL_LONGVARBINARY;
|
SqlType:=SQL_LONGVARBINARY;
|
||||||
end;
|
|
||||||
ftMemo:
|
|
||||||
begin
|
|
||||||
CType:=SQL_C_CHAR;
|
|
||||||
SqlType:=SQL_LONGVARCHAR;
|
|
||||||
end
|
|
||||||
else // ftString, ftFixedChar
|
|
||||||
begin
|
|
||||||
CType:=SQL_C_CHAR;
|
|
||||||
SqlType:=SQL_VARCHAR;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
ftString, ftFixedChar, ftMemo, ftGuid, // string parameters must be passed as widestring to support FPC 3.0.x character conversion
|
||||||
ftWideString, ftFixedWideChar, ftWideMemo:
|
ftWideString, ftFixedWideChar, ftWideMemo:
|
||||||
begin
|
begin
|
||||||
WideStrVal:=AParams[ParamIndex].AsWideString;
|
WideStrVal:=AParams[ParamIndex].AsWideString;
|
||||||
@ -492,7 +477,7 @@ begin
|
|||||||
BufferLength:=Size;
|
BufferLength:=Size;
|
||||||
CType:=SQL_C_WCHAR;
|
CType:=SQL_C_WCHAR;
|
||||||
case AParams[ParamIndex].DataType of
|
case AParams[ParamIndex].DataType of
|
||||||
ftWideMemo: SqlType:=SQL_WLONGVARCHAR;
|
ftMemo, ftWideMemo: SqlType:=SQL_WLONGVARCHAR;
|
||||||
else SqlType:=SQL_WVARCHAR;
|
else SqlType:=SQL_WVARCHAR;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user