BOOLEAN Calculated Field
BOOLEAN Calculated Field
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
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
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
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
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
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
I will add it to my framework for special occasions when needed.
Thanks,
Aggie85
Thanks,
Aggie85
Re: BOOLEAN Calculated Field
The TVirtualQuery's DataTypeMap did the trick.
Thanks,
Aggie85
Thanks,
Aggie85
Re: BOOLEAN Calculated Field
We are glad that we could find the solution, which helped to implement your projects.
Re: BOOLEAN Calculated Field
Most thanks!
All the best,
Aggie85
All the best,
Aggie85