function Round with params

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
abak
Posts: 29
Joined: Sat 18 Oct 2014 18:42

function Round with params

Post by abak » Thu 18 Mar 2021 18:06

Hello Devart,

I notice when the SQL contains function Round, it gives an error :
Exception Class EIBCError error with message :
"Dynamic SQL error expression evaluation not supported Invalid Data Type for Division in SQL 3".


The same code without Round, gives correct result.

Any Idea ?
Thx

Code: Select all

procedure TfrmAccueil.Operer(Trans:TIBCTransaction; C:TIBCConnection);
var MyQuery:TIBCSQL;

begin

    MyQuery:=TIBCSQL.Create(NIL);
    try
   //==========================================================

              MyQuery.Connection:=C;
              MyQuery.Transaction:=Trans;
              MyQuery.AutoCommit:=False;
              MyQuery.SQL.Clear;

              MyQuery.SQL.Add('Update MyTable Set');
              MyQuery.SQL.Add('FieldA  = Round(FieldB  / :P)');       // FieldA : integer        FieldB : Double Precision
              MyQuery.SQL.Add('Where (ID = :ID)');

              if not MyQuery.Prepared then MyQuery.Prepare;

               With MyQuery do
               begin
                 ParamByName('ID').DataType:=ftinteger;
                 ParamByName('ID').AsInteger:=1;

                 ParamByName('P').DataType:=ftFloat;
                 ParamByName('P').AsFloat:=10;
                end;

                MyQuery.Execute;

   //==========================================================
    finally
      MyQuery.Free;
    end;

end;
__________________
IBDAC : ibdac_7.4.1_d27std
Firebird-2.5.9.27139_0_Win32

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: function Round with params

Post by oleg0k » Wed 24 Mar 2021 07:41

Hello,
We couldn't reproduce the issue, unfortunately. Please send us an IBDAC-based sample application (including DDL scripts for creating and populating the database objects or the backup file/database file) demonstrating the incorrect behavior, using the form: https://devart.com/company/contactform.html

wbr, Oleg
Devart Team

abak
Posts: 29
Joined: Sat 18 Oct 2014 18:42

Re: function Round with params

Post by abak » Wed 31 Mar 2021 06:19

Hello Oleg,
Thank you.
I sent you a test case.

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: function Round with params

Post by oleg0k » Thu 01 Apr 2021 12:09

Hello,
The error is generated by the server on attempt to prepare your query. To eliminate the error, you can use the following query:
Update MyTable Set FieldA = Round(FieldB / cast( :p as float) )

wbr, Oleg
Devart Team

abak
Posts: 29
Joined: Sat 18 Oct 2014 18:42

Re: function Round with params

Post by abak » Thu 01 Apr 2021 20:18

Thx Oleg,
Great Suport :)

Post Reply