Page 1 of 1

Assigning a Currency type to a Param.value of an IBCQuery when Option.AutoPrepare = true

Posted: Wed 11 Jan 2017 17:43
by lam
I am assigning a Currency type variable to a Param.Value on an IBCQuery and it is passing a NULL value on Open (option AutoPrepare is true), it ignores the value I assigned. Here is an example of what I need to do:

Code: Select all

var CurrencyParam, CurrencyRes : Currency;
begin
  CurrencyParam := 4443.3232;
  with IBCQuery2 do
  begin
    Close;
    Options.AutoPrepare := true;
    SQL.Text := 'SELECT CURRENCY FROM CurrTest WHERE CURRENCY > :CURRENCY_MIN';
    ParamByName('CURRENCY_MIN').Value := CurrencyParam;
    Open;
    First;
    while not Eof do
    begin
      CurrencyRes := FieldByName('CURRENCY').AsCurrency;
      Memo1.Lines.Add('Result ' + floatToStr(CurrencyRes));
      Next;
    end; // while
  end;
If I do one of these things:
  • Use a variable of type Double or Extended.
  • Assign the value with the "AsCurrency" property instead of "Value".
  • Turn the Option.AutoPrepare off.
The value is passed CORRECTLY but in my situation I need to do it this way.

Thanks in advance.

Re: Assigning a Currency type to a Param.value of an IBCQuery when Option.AutoPrepare = true

Posted: Thu 12 Jan 2017 16:32
by ViktorV
Thank you for the information. We have reproduced the issue and investigation is in progress. We will inform you when we have any results.

Re: Assigning a Currency type to a Param.value of an IBCQuery when Option.AutoPrepare = true

Posted: Fri 13 Jan 2017 15:45
by lam
Thank you, please do.

Re: Assigning a Currency type to a Param.value of an IBCQuery when Option.AutoPrepare = true

Posted: Mon 16 Jan 2017 08:36
by ViktorV
Also as a workaround you can set the DataType property to ftCurrency before assigning a value to the parameter. For example:

Code: Select all

 
  ParamByName('CURRENCY_MIN').DataType := ftCurrency;
  ParamByName('CURRENCY_MIN').Value := CurrencyParam;