You are not logged in.
When I try to update a BLOB field in MS SQL Server 2008 with data more then 8000 bytes, it raises an error about "Invalid precision value".
In mORMot model field defined as TSQLRawBlob and it translated to varbinary(max) type in MS SQL table.
I found the same problem on StackOverflow: http://stackoverflow.com/questions/1486 … sion-value where recommend set len1 to 0:
SQLLEN len1 = 0;
SQLLEN nThisLen = (SQLLEN)sData.size();
SQLBindParameter( handle, (SQLUSMALLINT)4, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, len1, 0, (SQLCHAR*)&sData.c_str(), nThisLen, &nThisLen );
so, I tried to fix this in mORMot and this is work:
procedure TODBCStatement.ExecutePrepared;
...
status := ODBC.BindParameter(fStatement, p+1, InputOutputType, CValueType,
CType2SQL(CValueType), {ColumnSize}0, 0, ParameterValue, ColumnSize, StrLen_or_Ind[p]);
...
Also, this change tested on MySQL and PostgreSQL.
Is it correct fix?
Offline
Sounds fine to me.
The "official" documentation is really misleading and confusing...
Offline
I got the error "Invalid precision: cbColDef value out of range (0)" when tested on VARCHAR column in Teradata database.
Then I restored the change back and it worked.
I'm not sure if the change should be like this:
case VType of
ftBlob:
status := ODBC.BindParameter(fStatement, p+1, InputOutputType, CValueType,
CType2SQL(CValueType), 0, 0, ParameterValue, ColumnSize, StrLen_or_Ind[p]);
else
status := ODBC.BindParameter(fStatement, p+1, InputOutputType, CValueType,
CType2SQL(CValueType), ColumnSize, 0, ParameterValue, ColumnSize, StrLen_or_Ind[p]);
end;
Offline