Page 1 of 1
BOOLEAN Calculated Field
Posted: Wed 12 Jul 2017 04:36
by Aggie85
Howdy!
I have a calculated BOOLEAN column that I want to return with a SELECT set. Since BOOLEANs are stored as INTEGERs, the values are 0 for False and 1 for True.
That is,
SELECT <field 1>,<field 2>,0 AS Enabled
FROM <Table>
When I get the result set from TVirtualQuery and I try to copy the results to a TkbmMemTable, I am getting an error on the BOOLEAN field in the TkbmMemTable that 0 is NOT valid Boolean value for column 'Enabled'.
Any suggestions on how to fix this? All actual table boolean columns work fine.
All the best,
Aggie85
Re: BOOLEAN Calculated Field
Posted: Wed 12 Jul 2017 07:58
by MaximG
Thank you for the information. Unfortunately, we could not reproduce the problem according to your description. Please compose and send us via the e-support form (
https://www.devart.com the "Support"\"Request Support" menu) a small complete sample in which the problem occurs.
Re: BOOLEAN Calculated Field
Posted: Wed 12 Jul 2017 12:05
by Aggie85
Good day Maxim!
The problem is the constant field I am adding in the SELECT statement returns fine from TVirtualQuery, but when I try to copy the returned data to a TkbmMemTable dataset, I get the error.
I have even tried
SELECT <field 1>,<field 2>,(CAST 0 AS BOOLEAN) AS Enabled
FROM <Table>
And I get the same error. How can I get TVirtualQuery to make sure Enabled is a BOOLEAN in the return dataset (the field doesn't exist in any underlying dataset in the SELECT - it is a calculated field for the resulting dataset the data will be copied into).
Thanks,
Aggie85
Re: BOOLEAN Calculated Field
Posted: Wed 12 Jul 2017 14:04
by MaximG
To execute the described queries using VirtualQuery, you can use DataTypeMapping. For this, before opening the query, create the following rule :
Code: Select all
VirtualQuery.DataTypeMap.AddFieldNameRule('Enabled', ftBoolean);
Re: BOOLEAN Calculated Field
Posted: Wed 12 Jul 2017 14:29
by Aggie85
I will add it to my framework for special occasions when needed.
Thanks,
Aggie85
Re: BOOLEAN Calculated Field
Posted: Wed 12 Jul 2017 20:11
by Aggie85
The TVirtualQuery's DataTypeMap did the trick.
Thanks,
Aggie85
Re: BOOLEAN Calculated Field
Posted: Thu 13 Jul 2017 07:10
by MaximG
We are glad that we could find the solution, which helped to implement your projects.
Re: BOOLEAN Calculated Field
Posted: Thu 13 Jul 2017 17:04
by Aggie85
Most thanks!
All the best,
Aggie85