QueryRecCount with SQL Server

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Licences AAW
Posts: 10
Joined: Tue 21 Jul 2015 07:43

QueryRecCount with SQL Server

Post by Licences AAW » Thu 12 Nov 2015 14:56

{UniDac 6.1.5}

Hi,

I've got a query like this to run on a SQL Server:

Code: Select all

select * from t1 order by right(f1, 3) desc
If the QueryRecCount property is not activated, the query is run successfully.

But, when the property is activated, TUniQuery complains about a bad syntax near '(' when asking for the record count.
Indeed, the generated query is:

Code: Select all

SET :PCOUNT = (SELECT COUNT(*) from t1 right(f1, 3) desc)
It seems _SetOrderBy procedure in CRParser unit doesn't support "calculated" order by.
A way to get my query run is to enclose each order by "calculated" field with parenthesis.

It would be convenient that this workaround is not mandatory.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: QueryRecCount with SQL Server

Post by AlexP » Thu 12 Nov 2015 16:42

Hello,

Specially for "complex" queries we have added possibility to set user SQL query for defining the number of records. For this, in design time you can set a "correct" query on the Update SQLs tab in the UniQuery editor, in runtime - in the UniQuery1.SQLRecCount property.

Licences AAW
Posts: 10
Joined: Tue 21 Jul 2015 07:43

Re: QueryRecCount with SQL Server

Post by Licences AAW » Fri 13 Nov 2015 08:09

Thank's for the answer

I didn't know the property (because I create all my queries dynamically, I don't use design time editors)

Regards

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: QueryRecCount with SQL Server

Post by AlexP » Fri 13 Nov 2015 12:45

If you have any other questions, feel free to contact us.

Post Reply