|
@@ -147,7 +147,7 @@ type
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
- Math, DBConst;
|
|
|
|
|
|
+ Math, DBConst, ctypes;
|
|
|
|
|
|
const
|
|
const
|
|
DefaultEnvironment:TODBCEnvironment = nil;
|
|
DefaultEnvironment:TODBCEnvironment = nil;
|
|
@@ -303,9 +303,11 @@ var
|
|
ParamIndex:integer;
|
|
ParamIndex:integer;
|
|
Buf:pointer;
|
|
Buf:pointer;
|
|
I:integer;
|
|
I:integer;
|
|
- IntVal:longint;
|
|
|
|
|
|
+ IntVal:clong;
|
|
StrVal:string;
|
|
StrVal:string;
|
|
StrLen:SQLINTEGER;
|
|
StrLen:SQLINTEGER;
|
|
|
|
+ CType:SQLSMALLINT;
|
|
|
|
+ SqlType:SQLSMALLINT;
|
|
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
|
|
@@ -323,9 +325,9 @@ begin
|
|
case AParams[ParamIndex].DataType of
|
|
case AParams[ParamIndex].DataType of
|
|
ftInteger:
|
|
ftInteger:
|
|
begin
|
|
begin
|
|
- Buf:=GetMem(4);
|
|
|
|
|
|
+ Buf:=GetMem(Sizeof(clong));
|
|
IntVal:=AParams[ParamIndex].AsInteger;
|
|
IntVal:=AParams[ParamIndex].AsInteger;
|
|
- Move(IntVal,Buf^,4);
|
|
|
|
|
|
+ Move(IntVal,Buf^,Sizeof(clong));
|
|
ODBCCursor.FParamBuf[i]:=Buf;
|
|
ODBCCursor.FParamBuf[i]:=Buf;
|
|
ODBCCheckResult(
|
|
ODBCCheckResult(
|
|
SQLBindParameter(ODBCCursor.FSTMTHandle, // StatementHandle
|
|
SQLBindParameter(ODBCCursor.FSTMTHandle, // StatementHandle
|
|
@@ -341,7 +343,7 @@ begin
|
|
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not bind (integer) parameter %d.', [i]
|
|
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not bind (integer) parameter %d.', [i]
|
|
);
|
|
);
|
|
end;
|
|
end;
|
|
- ftString:
|
|
|
|
|
|
+ ftString, ftBlob:
|
|
begin
|
|
begin
|
|
StrVal:=AParams[ParamIndex].AsString;
|
|
StrVal:=AParams[ParamIndex].AsString;
|
|
StrLen:=Length(StrVal);
|
|
StrLen:=Length(StrVal);
|
|
@@ -349,12 +351,22 @@ begin
|
|
Move(StrLen, buf^, SizeOf(SQLINTEGER));
|
|
Move(StrLen, buf^, SizeOf(SQLINTEGER));
|
|
Move(StrVal[1],(buf+SizeOf(SQLINTEGER))^,StrLen);
|
|
Move(StrVal[1],(buf+SizeOf(SQLINTEGER))^,StrLen);
|
|
ODBCCursor.FParamBuf[i]:=Buf;
|
|
ODBCCursor.FParamBuf[i]:=Buf;
|
|
|
|
+ if AParams[ParamIndex].DataType = ftString then
|
|
|
|
+ begin
|
|
|
|
+ CType:=SQL_C_CHAR;
|
|
|
|
+ SqlType:=SQL_CHAR;
|
|
|
|
+ end
|
|
|
|
+ else // ftBlob
|
|
|
|
+ begin
|
|
|
|
+ CType:=SQL_C_BINARY;
|
|
|
|
+ SqlType:=SQL_BINARY;
|
|
|
|
+ end;
|
|
ODBCCheckResult(
|
|
ODBCCheckResult(
|
|
SQLBindParameter(ODBCCursor.FSTMTHandle, // StatementHandle
|
|
SQLBindParameter(ODBCCursor.FSTMTHandle, // StatementHandle
|
|
i+1, // ParameterNumber
|
|
i+1, // ParameterNumber
|
|
SQL_PARAM_INPUT, // InputOutputType
|
|
SQL_PARAM_INPUT, // InputOutputType
|
|
- SQL_C_CHAR, // ValueType
|
|
|
|
- SQL_CHAR, // ParameterType
|
|
|
|
|
|
+ CType, // ValueType
|
|
|
|
+ SqlType, // ParameterType
|
|
StrLen, // ColumnSize
|
|
StrLen, // ColumnSize
|
|
0, // DecimalDigits
|
|
0, // DecimalDigits
|
|
buf+SizeOf(SQLINTEGER), // ParameterValuePtr
|
|
buf+SizeOf(SQLINTEGER), // ParameterValuePtr
|