Page 1 of 1
Problem adding calculated field to a query
Posted: Wed 28 Jun 2017 22:25
by sandy771
I am having problems adding a calculated field to a query at run time
The following query fails with an exception
Code: Select all
UniQuery1->SQL->Clear();
UniQuery1->SQL->Text = "select count(*) as rowcount from sqlite_master"
UniQuery1->FieldDefs->Update();
TField *field;
for (int f = 0; f < UniQuery1->FieldDefs->Count; f++)
field = UniQuery1->FieldDefs->Items[f]->CreateField(UniQuery1);
TIntegerField *field2;
field2 = new TIntegerField(UniQuery1);
field2->FieldName = "id";
field2->FieldKind = fkCalculated;
field2->DataSet = UniQuery1;
UniQuery1->Open();
while(!UniQuery1->Eof)
{
for(int i=0; i<UniQuery1->FieldCount; i++)
{
f = UniQuery1->Fields->FieldByNumber(i+1); <-- results in exception "Error Field is not BLOB"
}
}
However if I do not add the additional integer field, and just execute the query it runs OK.
Code: Select all
UniQuery1->SQL->Clear();
UniQuery1->SQL->Text = "select count(*) as rowcount from sqlite_master"
UniQuery1->Execute();
TField *f;
for(int i=0; i<UniQuery1->FieldCount; i++)
{
f = UniQuery1->Fields->FieldByNumber(i+1);
}
Obviously I need to provide a value for the id field in OnCalcfields - but there is something else I am doing wrong
Re: Problem adding calculated field to a query
Posted: Fri 30 Jun 2017 14:35
by MaximG
Thank you for the information. Unfortunately, we could not reproduce the problem according to the description. For further problem investigation, please compose and send us via the e-support form (
https://www.devart.com menu "Support"\"Request Support" ) a small complete sample, execution of which causes the problem. In addition, we will need SQLite DB used in this sample.
Re: Problem adding calculated field to a query
Posted: Mon 03 Jul 2017 08:44
by sandy771
Hi Maxim
Thank You
I have sent a sample simple project via the link (and sent the same by email on Friday afternoon last week).
Please let me know if there is anything else I can do
Paul
Re: Problem adding calculated field to a query
Posted: Mon 03 Jul 2017 14:20
by MaximG
Thank you for the information, we received your sample and reproduced the described error. The difference in the behavior of UniDAC when using the CreateField method and without it is explained by the peculiarities of using SQLite database. In the first case, when working with the CreateField method and before opening a query, SQLite cannot determine the type of the ROWCOUNT field. Therefore, in this case, UniDAC will create such a field as TMemoField, what leads to a further error in your code. In the second case, the ROWCOUNT field will be represented as TLargeIntField, which is the correct behavior. We will fix UniDAC behavior and let you know about the results in the near future.
Re: Problem adding calculated field to a query
Posted: Tue 04 Jul 2017 09:24
by sandy771
Thank You Maxim
I look forward to receiving a fix
Re: Problem adding calculated field to a query
Posted: Tue 04 Jul 2017 15:00
by MaximG
Thank you for the information. We have reproduced the problem and fixed the bug. The fix will be included in the next UniDAC build. Currently, we can send you a night build of UniDAC with the fix. For this, please specify your license number and and the exact version of RAD Studio you are using via the e-support form (
https://www.devart.com menu "Support"\"Request Support" )
Re: Problem adding calculated field to a query
Posted: Tue 04 Jul 2017 15:10
by sandy771
Hi Maxim
Thank You for fixing this so promptly.
I have provided the details asked for via the support link.
Cheers
Re: Problem adding calculated field to a query
Posted: Wed 05 Jul 2017 08:29
by sandy771
Hi Maxim
I filled in the form yesterday as requested, but have not received the night build yet. How do I get this?
The next stage of my development requires this fix so everything is on hold here
Cheers
Paul
Re: Problem adding calculated field to a query
Posted: Wed 05 Jul 2017 11:38
by MaximG
The links to download UniDAC night build with the made fixes were sent to your email
Re: Problem adding calculated field to a query
Posted: Wed 05 Jul 2017 11:49
by sandy771
Thank you - got the email an hour ago
Re: Problem adding calculated field to a query
Posted: Mon 10 Jul 2017 12:41
by MaximG
Please specify whether the described problem is reproduced or not when using the sent night build
Re: Problem adding calculated field to a query
Posted: Mon 10 Jul 2017 13:13
by sandy771
All seems OK now thank you.
Re: Problem adding calculated field to a query
Posted: Mon 10 Jul 2017 14:56
by MaximG
We are glad to see the problem resolved. Please don't hesitate to contact us with questions concerning UniDAC usage.