Solved

problem with locate method

Posted on 2002-05-02
5
956 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

14 Experts available now in Live!

Get 1:1 Help Now