Clear dataset

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
clebernardelli
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 19.09.2006, 16:04
Location: Rio do Sul, SC

Clear dataset

Post 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
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post 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.)
clebernardelli
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 19.09.2006, 16:04
Location: Rio do Sul, SC

I´m using ORACLE

Post by clebernardelli »

I go to try way SQL. But I am using ORACLE and the functions are a little different.

But Thanks.
bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Post 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.
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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 :)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
clebernardelli
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 19.09.2006, 16:04
Location: Rio do Sul, SC

Post 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.
mwgomez
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 11.07.2006, 16:02

Post 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
bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Post 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.
clebernardelli
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 19.09.2006, 16:04
Location: Rio do Sul, SC

Memory continues High

Post 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.
bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Post 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
Post Reply