Board index » delphi » BDE Able to sort a Qry result set??

BDE Able to sort a Qry result set??

Is it possible for the BDE to sort a query result set returned from a
SQL Anywhere server?

I know I can get the server to sort it before it sends the data but I
have a need to change the order after it arrives.

Thanks,

Glenn.

 

Re:BDE Able to sort a Qry result set??


Glenn,

   You can try storing your query results in a temporary table, and
performing your sorts on that temporary table.
In my application (to MS SQL 6.5),  the user searches for a customer and
the result set is returned in a DBGrid (InfoPower DBGrid with title buttons
to be more exact).  The user wanted to be able to sort by clicking on the
column title, both ascending and descending (very Explorer like).  No
problem, but executing the same query, ascending and descending, over
800,000 records did take some time.  I used temporary tables to solve this
problem.
For example:

MyQuery.SQL.Add('Select * into #Temp');
MyQuery.SQL.Append('from Customers');
MyQuery.SQL.Append('Where FirstName = "Kevin" ');
MyQuery.Prepare;
MyQuery.Open;
{ other code .....}
.
MyQuery.Close;
MyQuery.SQL.Clear;
MyQuery.SQL.Add('Select * from #Temp');
MyQuery.Prepare;
MyQuery.Open;

- and from there just appended the 'ORDER BY <field name>'  and re-executed
the query.  Performance is very fast, but I found this could fill up tempdb
if users execute querys that return large datasets (like getting every
customer with first name of Kevin)  

I hope this helps.

Good luck,
krf

Glenn Casteran <Lag...@{*word*104}Force.com> wrote in article
<348CCD31.1...@{*word*104}Force.com>...

Quote
> Is it possible for the BDE to sort a query result set returned from a
> SQL Anywhere server?

> I know I can get the server to sort it before it sends the data but I
> have a need to change the order after it arrives.

> Thanks,

> Glenn.

Re:BDE Able to sort a Qry result set??


Glenn

Can't you sort the query before your app gets it using the SQL ORDER BY
clause?

Derek Davidson
Author of DK's Audit Components
Get a FREE copy from my web site at :
http://freespace.{*word*269}.net/d.davidson

(Remove the x to EMail me : der...@mksoft.com)

Re:BDE Able to sort a Qry result set??


Quote
Derek Davidson wrote:

> Can't you sort the query before your app gets it using the SQL ORDER BY
> clause?

I already said that I could do that for the initial fetch from the
server. The problem is as Kevin mentioned that the client wants to see
the list ordered in different orders once it is compiled. I wanted to
eliminate the delay of getting a NEW list from the server, and our user
will be entering values against the rows and we have to find and replace
those values if we fetch a new result set.

I like Kevin's option better.

Thanks,

Glenn.

Other Threads