Subject Re: [IBO] Volume Data Adding
Author Geoff Worboys
> Thanks, I used the column reference method (ib_dsql.Params[0].astype
> := x) and it has knocked nearly 50% off my excecution time. I'm
> well pleased, I just wish I'd discovered it three months ago!

Now you know why we emphasis this rather than *ByName.


> I just have one question. I am a bit confused as to where I need
> to put the beginbusy and the try statements. My code is structured
> like this:

BeginBusy/EndBusy is passed through to the IB_Session for the
component (and all your components in this situation are presumably
using the default and only IB_Session). The functions were made
available via the TIB_* components (TIB_DSQL, TIB_Query,
TIB_Transaction etc) mostly to make them easy to access. You really
only need to call it once for your entire process. Just make sure you
use the same component for EndBusy that you used for BeginBusy.

So pick a component, any TIB_* component and use it around the entire
block. eg.

transaction.BeginBusy(true)
try
do everything
finally
transaction.EndBusy;
end;



> if mainloop counter mod 50 = 0
> transaction.commit

may I suggest you expand this to...

if mainloop counter mod 50 = 0 then
begin
transaction.commit;
application.processmessages;
end;

as this will make your application more responsive (otherwise it
appears to be locked until your process is complete). It is also an
ideal location to put in user feedback and checking for user abort.


> I'm thinking that the beginbusy/try should to go outside of the
> main loop with the last commit going in the "finally" command.
> Does this sound right or should there be seperate beginbusy/try's
> for the inner loops?

As you saw above, this is mostly right but remember that want to be
sure the EndBusy is called. I prefer not to put the last commit
inside the finally. Either put it immediately before finally, or
after finally..end; If you do want to put it inside finally (perhaps
you have some reason for wanting to try the commit even after error)
do the EndBusy FIRST to be sure it gets done, or use two try finally
blocks - one inside the other.

eg.
transaction.BeginBusy(true)
try
do everything
finally
transaction.EndBusy;
transaction.Commit;
end;

or
try
transaction.BeginBusy(true)
try
do everything
finally
transaction.EndBusy;
end;
finally
transaction.Commit;
end;


As a note to anyone else reading this. I generally use something like
the following (with no intermediate commits during the loop), because
in most situations I prefer everything to be saved or nothing. Paul,
I am assuming this situation is slightly different and for some reason
and you are content that only part of the processing may complete and
be saved.

transaction.BeginBusy(true)
try
do everything
transaction.Commit;
finally
transaction.EndBusy;
end;


HTH

Geoff Worboys
Telesis Computing