BOOLEAN Calculated Field

BOOLEAN Calculated Field

Postby Aggie85 » Wed 12 Jul 2017 04:36

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
Aggie85
 
Posts: 66
Joined: Wed 11 Nov 2015 17:03

Re: BOOLEAN Calculated Field

Postby MaximG » Wed 12 Jul 2017 07:58

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.
MaximG
Devart Team
 
Posts: 668
Joined: Mon 06 Jul 2015 11:34

Re: BOOLEAN Calculated Field

Postby Aggie85 » Wed 12 Jul 2017 12:05

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
Aggie85
 
Posts: 66
Joined: Wed 11 Nov 2015 17:03

Re: BOOLEAN Calculated Field

Postby MaximG » Wed 12 Jul 2017 14:04

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);
MaximG
Devart Team
 
Posts: 668
Joined: Mon 06 Jul 2015 11:34

Re: BOOLEAN Calculated Field

Postby Aggie85 » Wed 12 Jul 2017 14:29

I will add it to my framework for special occasions when needed.

Thanks,

Aggie85
Aggie85
 
Posts: 66
Joined: Wed 11 Nov 2015 17:03

Re: BOOLEAN Calculated Field

Postby Aggie85 » Wed 12 Jul 2017 20:11

The TVirtualQuery's DataTypeMap did the trick.

Thanks,

Aggie85
Aggie85
 
Posts: 66
Joined: Wed 11 Nov 2015 17:03

Re: BOOLEAN Calculated Field

Postby MaximG » Thu 13 Jul 2017 07:10

We are glad that we could find the solution, which helped to implement your projects.
MaximG
Devart Team
 
Posts: 668
Joined: Mon 06 Jul 2015 11:34

Re: BOOLEAN Calculated Field

Postby Aggie85 » Thu 13 Jul 2017 17:04

Most thanks!

All the best,

Aggie85
Aggie85
 
Posts: 66
Joined: Wed 11 Nov 2015 17:03


Return to VirtualDAC