Errors setting params
Posted: Mon 10 Nov 2014 06:57
Using PgDAC 4.4.11. I've run into two separate errors when setting query parameters.
#1.
The query returns something like '2014-12-15 13:08:40', but the value is not consistent. The bug appears to be in TCustomPgTimeStamp.FromString() - when the string has no time portion, the TimeZoneOffset variable is never initialised.
#2.
When setting a param value as a variant, if the param's DataType is already defined, it does not get updated:
In this particular case, it causes Query.Open to raise an exception - TCustomDASQL.AssignParamValue() has a case for "DataType = ftDate", and tries to cast the string to an integer, which fails with an EVariantTypeCastError.
It seems I can avoid this error by setting "Param.DataType := ftUnknown" before assigning Param.Value... Would this be a safe / sensible workaround?
#1.
Code: Select all
Query.SQL.Text := 'SELECT CAST(:Date AS timestamp)';
Query.ParamByName('Date').Value := '2015-01-01';
#2.
When setting a param value as a variant, if the param's DataType is already defined, it does not get updated:
Code: Select all
Query.SQL.Text := 'SELECT CAST(:Date AS timestamp)';
Query.ParamByName('Date').Value := '2015-01-01'; // DataType is ftWideString
Query.ParamByName('Date').AsDate := Now; // DataType is ftDate
Query.ParamByName('Date').Value := '2015-01-01'; // DataType is ftDate
Query.Open;
It seems I can avoid this error by setting "Param.DataType := ftUnknown" before assigning Param.Value... Would this be a safe / sensible workaround?