Params error

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
malmedin
Posts: 10
Joined: Fri 26 Mar 2010 19:52

Params error

Post by malmedin » Tue 28 Jul 2020 12:03

I have a table with column NAME VARCHAR(10).

This code (q is TIBCQuery):

Code: Select all

  q.SQL.Text := 'SELECT * FROM Test WHERE Name = :value';
  q.Params.Items[0].AsString := '12345678901';
  q.Open;
produces this error message:
Dynamic SQL Error SQL error code = -303
arithmetic exception, numeric overflow, or string truncation
string right truncation
expected length 10, actual 11
Note the param size (11).

Executing

Code: Select all

SELECT * FROM Test WHERE Name = '12345678901'
gives no error.

IBDAC version 7.2.4, Delphi 7, Firebird 3

Edit:
It seems this is message from Firebird and this behavior is by design. Can IBDAC do something about it?

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

Re: Params error

Post by oleg0k » Wed 29 Jul 2020 08:21

Hello,
This behavior (error) is caused by the Firebird fbclient.dll client library rather than our components. The same error occurs with standard Delphi components (FireDAC).

wbr, Oleg
Devart Team

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

Re: Params error

Post by oleg0k » Wed 29 Jul 2020 11:31

Hello,
To resolve the issue, you can try to explicitly specify the parameter size:

Code: Select all

q.Params.Items[0].Size:=10;
IBDAC also has the DescribeParams property:

Code: Select all

q.Options.DescribeParams := True
See our documentation for information on DescribeParams: https://www.devart.com/ibdac/docs/devar ... params.htm

wbr, Oleg
Devart Team

malmedin
Posts: 10
Joined: Fri 26 Mar 2010 19:52

Re: Params error

Post by malmedin » Thu 30 Jul 2020 06:28

Hello oleg0k,

Thank you for answer.

DescribeParams is what I was looking for.

Setting parameter size also works but q.Prepare has to be called before.

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

Re: Params error

Post by oleg0k » Wed 05 Aug 2020 08:25

Hello,
Thank you for the interest to our product.
It is good to see that the problem has been solved.
If you have any questions during using our products, please don't hesitate to contact us - and we will try to help you solve them.

wbr, Oleg
Devart Team

Post Reply