I have a problem, that came up recently, when trying to pass boolean parameters to a stored procedure in Firebird 3.
For boolean I use a domain "dom_boolean" that is declared as a char (1) and holds 'T' for true and 'F' for false.
Now I have a stored procedure with boolean parameters. Somthing like this:
create procedure someprocedure (par1 dom_boolean)
returns (result integer) as
begin
.....
suspend;
end^
In Delphi I use it like:
somebooleanvariable := true;
.....
query.sql.text := 'select result from someprocedure (:par1)';
query.parambyname ('par1').asboolean := somebooleanvariable;
query.open;
In Firebird 2.5 that works fine. In Firebird 3.0 I get an exception with something like that "arithmetic exception, numeric overflow, or string truncation string right truncation" and it claims that length should by 4 but is only 1.
So it looks to me, that the type of the boolean parameter should be a 4 byte type and not a 1 byte, like my dom_boolean.
Unfortunately that worked for years with Firebird 2.5 and I have many of that in my projects.
I made a quick and dirty workaround to use parambyname ('par1').asstring and assign 'T' or 'F' depending if it should be true or false, but that is a bit of a mess, because I always have to pay attention to not use asboolean for parameters and
query.parambyname ('par1').asboolean := somebooleanvariable;
is way better than
if somebooleanvariable then
query.parambyname ('par1').asstring := 'T'
else
query.parambyname ('par1').asstring := 'F';
Any suggestions how to deal with that or explanation why this has changed with FB3?
Problem with boolean parameter in FB3
Re: Problem with boolean parameter in FB3
Thank you for the information.
We investigated the problem and found that this error is caused by the specifics of the Firebird 3 functionality, in which the BOOLEAN data type was added. We investigated this feature and inform you about the result.
As a temporary solution, you can use the following string
instead of
We investigated the problem and found that this error is caused by the specifics of the Firebird 3 functionality, in which the BOOLEAN data type was added. We investigated this feature and inform you about the result.
As a temporary solution, you can use the following string
Code: Select all
query.parambyname ('par1'). AsInteger: = Integer (somebooleanvariable);
Code: Select all
query.parambyname ('par1').asboolean := somebooleanvariable;
Re: Problem with boolean parameter in FB3
Thanks for the quick reply.
The problem ist, that I use a char(1) as boolean and that contains 'T' or 'F'.
In the stored procedure I use something like that:
if (:par1 = 'T') then
.......
So when I use
query.parambyname ('par1'). AsInteger: = Integer (somebooleanvariable);
I think it would not deliver 'T' or 'F' but 1 and 0 to the stored procedure.
So have to use asstring and pas 'T' or 'F' to it, depending on somebooleanvariable is true or false.
The problem ist, that I use a char(1) as boolean and that contains 'T' or 'F'.
In the stored procedure I use something like that:
if (:par1 = 'T') then
.......
So when I use
query.parambyname ('par1'). AsInteger: = Integer (somebooleanvariable);
I think it would not deliver 'T' or 'F' but 1 and 0 to the stored procedure.
So have to use asstring and pas 'T' or 'F' to it, depending on somebooleanvariable is true or false.
Re: Problem with boolean parameter in FB3
We have answered you via e-mail.
Re: Problem with boolean parameter in FB3
Yes, thank you. I am working on an example. Will take some time, but I hope I will have it ready in the next few days.
Re: Problem with boolean parameter in FB3
Thank you for the interest to our product.
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.
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.