#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?