Page 1 of 1

Question about Boolean and Parameters

Posted: Thu 29 Jan 2009 13:48
by swierzbicki
Hi,

I'm using such kind of SQL Script :

Code: Select all

SET @Value = :prvalue;
Select 
(case 
when @Value  then 'True' 
when not @Value then 'False'  
else '?' end)
as Test
When setting my parameter like this :

Code: Select all

MyQuery.Parambyname('prvalue').AsBoolean := False;
or
MyQuery.Parambyname('prvalue').AsBoolean := True;
Test is always 'False' !

When setting my parameter like this :

Code: Select all

MyQuery.Parambyname('prvalue').AsInteger := 0;
or
MyQuery.Parambyname('prvalue').AsInteger := 1;
Test is either True or False

How can I get this to work with parameters as boolean ?

Posted: Fri 30 Jan 2009 13:10
by Dimon
This behaviour is connected with specificity of work of MySQL server with Boolean type. MySQL uses one format for parameters in SELECT, INSERT, UPDATE and other statements, but in your case MySQL uses another format.
You may use AsInteger as a workaround for the problem.

Posted: Mon 02 Feb 2009 07:10
by swierzbicki
Hi Dimon,

Casting to an integer is fine for me. I'm doing this as a workaround :

Code: Select all

MyQuery.Parambyname('prvalue').AsInteger := Integer(MyBooleanVariable);
I think there is still an issue since nothing seems to be passed to the parameter when using .AsBoolean :

Code: Select all

SET @Value = :prvalue;
Select @Value;
@Value is always blank (or null, need to check this) when using :

Code: Select all

MyQuery.Parambyname('prvalue').AsBoolean := False;
or
MyQuery.Parambyname('prvalue').AsBoolean := True;

Posted: Mon 02 Feb 2009 13:05
by Dimon
We have fixed this problem. This fix will be included in the next MyDAC build.

Posted: Mon 02 Feb 2009 19:29
by swierzbicki
that's great !
Thank you