Our application updates and accesses data using SQL Server 2014.
I have a table of which the last column ('Contents') is created as VARCHAR(MAX).
We are using Delphi XE8, and are using a FireDAC TFDQuery component to update this column.
.....
FDquery.ParamByName('Contents').AsString:=Contents;
FDquery.ExecSQL;
When running this update, I get the following error:
Exception raised with message [FireDAC][Phys][ODBC]-345. Data too large for variable [CONTENTS]. Max len = [8002], actual len = [13829] Hint: set the TFDParam.Size to a greater value.
'Contents' can be string of varying length.
Browsing the web, the only reasonably simple solution that I found is changing the query as follows:
FDquery.ParamByName('Contents').AsWideMemo:=Contents;
FDquery.ExecSQL;
Is this acceptable, or should I be handling this differently?
There is nothing fancy with 'Contents', as I mentioned, it is simply a long string.
AsStringyou claim that the parameter is of data typeftStringorftWideStringand values are send to the DBMS accordingly. And becauseft(Wide)Stringis for SQL server mapped to data types that can be at most 8k chars long, you receive such error. If you access that parameter byAs(Wide)Memo, it is handled asftMemofield. The whole point is thatAs<>access modifies parameterDataTypeand the value is send by that to DBMS. - Victoria