Page 1 of 1

Clear dataset

Posted: 26.09.2006, 18:21
by clebernardelli
Necessary to make with that one result set can be clean without query either closed.

That is I have an instruction SQL that has 1000 rows and am reading (query.next). When to reach 100 records I want to continue reading but I want that the 100 read records already are eliminated of resultset.

Thanks. :D

Posted: 26.09.2006, 19:52
by zippo
More ways to do that:

a) via SQL:

Code: Select all

Select * from Table limit 0,100
Select * from limit 100,100 
Select * from limit 200,100 
...
(more on http://dev.mysql.com/doc/refman/5.1/en/select.html)

b) via cached datasets. Make the property Query.CachedUpdates := true and then Query.Delete without affecting the "real" database table. After you finished just call Query.CancelUpdates or close a dataset withou posting the changes (this is done with Query.ApplyUpdates then Query.CommitUpdates) - read the Delphi help for more.

c) Try to use a more efficent way, I suggest you to process as much as you can on the server (more SQLs, if possible stored procedures, .. etc.)

I´m using ORACLE

Posted: 26.09.2006, 20:25
by clebernardelli
I go to try way SQL. But I am using ORACLE and the functions are a little different.

But Thanks.

Posted: 27.09.2006, 05:16
by bangfauzan
clebernardelli,
I understand what you mean.
I also ned the "EmptyDataSet" property on Zeos Dataset like TClientDataSet and SimpleDataSet. Hope Zeos Team would provide it.
thanks.

Posted: 27.09.2006, 14:01
by gto
This is a tricky problem, and in most times can be fixed with a better system design, like using limits (MySQL) and first (Firebird).

About limiting resultset to certain records on oracle, take a look here:

http://blog.dataloss.nl/perma/oracle-limit
http://edocs.bea.com/workshop/docs81/do ... index.html
http://forum.java.sun.com/thread.jspa?t ... ID=3233484


About CDS, take a look here:
Applications that need to represent extremely large read-only datasets can turn off FetchOnDemand to ensure that the client datasets do not try to load more data than can fit into memory. Between fetches, the client dataset frees its cache using the EmptyDataSet method. This approach, however, does not work well when the client must post updates to the application server.
http://podgoretsky.com/ftp/Docs/Delphi/D5/dg/5_ds3.html

It's a marvelous component, but should be used with care :)

Posted: 29.09.2006, 12:30
by clebernardelli
My problem is the following one: I have one query (ZReadOnlyQuery) that he prossess a command SQL that returns many rows (200000). Then if I to make readings with paging I finish very being slow at certain moment. If not I as the reading happens the program goes consuming CPU resources until the point where the Windows accuses memory low, the computer stops.

The Correct one would not be to more paging but clean the resultset of query that already it was read so that the memory is set free.

Posted: 29.09.2006, 14:57
by mwgomez
What about useing StringGrid?
You are reading record and omit the first 100, and needed place into
the grid. It gives more solutions then useing DBGird.


Regards
mwgomez

Posted: 04.10.2006, 02:15
by bangfauzan
I propose 2 solution about this problem.

First, you can use both TClientDataSet and TDataSetProvider. Set DataSet property of TDataSetProvider to your ZTable or ZQuery, and then set ProviderName property of TClientDataSet to the such TDataSetProvider.
now you your TClientDataSet ready to use. The point is, if you use TClientDataSet, you can clear your dataset becouse TClientDataSet has EmptyDataSet procedure.

Second, I have posted the new features of zeoslib which cotain EmptyDataSet procedure (like TClientDataSet). with the new LIB you don't need TClientDataSet anymore. you can download it from this forum at Subject "New ZeodLib: How To Post?" or you can wait for the moment until new SVN released.

Thanx.

Memory continues High

Posted: 06.10.2006, 17:34
by clebernardelli
OK.

I made the Download of units and functioned the EmptyDataSet. But I continue with a problem, the memory used for the operational system (win XP) for the application is not lowering when the EmptyDataSet is executed.

This is normal?

Thanks.

Posted: 13.10.2006, 06:58
by bangfauzan
I made a hard tes and I used it in production environment, every ok, no memory leak found.
Try to check your code again, and remove/modify any inefficient algorithme.

Thanks