Solved

problem with locate method

Posted on 2002-05-02
5
958 Views
Last Modified: 2012-06-21
Hello.
I'm having memory problems when using the locate method. I'm using an
IBTable(Interbase). I've also tried with IBDataSet. The problem is the same.
The strange thing is that it depends on the tables I use...
When I do the following code:

FrmDados.Tabela_Amostra.active:=TRUE;
existe:=FrmDados.Tabela_Amostra.locate('chave_carta_fk;num_amostra',VarArray
Of([car.chave_carta,namo]),[]);

the memory allocated increases a lot (sometimes 3 times more; I'm checking
the memory with GetHeapStatus.TotalAllocated).
But when I run this code:

FrmDados.Tabela_Pesagem.active:=TRUE;
existe:=FrmDados.Tabela_pesagem.locate('chave_amostra_fk;n',VarArrayOf([chav
e_a,pes.N]),[]);

the memory sometimes decreases!!!! The tables are not the same, but the
second table has more records than the first!
Can anyone give me some tips on how to avoid this memory problem?
Thanks

Goncalo

0
Comment
Question by:gmartins77
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 35 total points
ID: 6986908
o yes,
use a query and a whereclause

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6986946
if you do not want a query,
then supply the table with indexes on the to locate fields

meikl ;-)
0
 
LVL 3

Expert Comment

by:VSF
ID: 6988377
A locate should be that last thing to be used in order not to increase the memory usage!
U should also take a look at IBSQL component in order to execute a query with a minimum overhead!

Espero q tenha ajudado! (Vi o português no nome das suas tabelas).

VSF
www.victory.hpg.com.br
www.boatoda.hpg.com.br
www.enge.cjb.net
 
0
 
LVL 2

Assisted Solution

by:dMa
dMa earned 35 total points
ID: 6988832
please use a Query and use anytime an index in your tables ! ... idexes are everytime very usefull :)

sample for an query :
SELECT * FROM (tablename) WHERE (FIELDNAME)=:PARAM

in your params you have to declare an parameter names PARAM

in code :
query.params('PARAM').As(Integer , string ,blob) := (you variable) ;
query.execute;

thet's all :)
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9004510
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between kretzschmar and dMa

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 127
Delphi Form ownership 4 73
oracle global variables 4 63
Open a URL with Internet Explorer in a new tab (not a new window) 1 74
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now