Subject Prepared and unprepared
Author Tim Ledgerwood
Hi all,

I have several static queries, several dynamic queries (where the SQL text
of the TIB_Query object is determined when the user makes the query) and
several stored procedures in my application.

I have (for years) used something like the following to execute these kinds
of SQL :

with MyQuery do
if not TIB_Transaction.InTransaction then

if active then close;
if not TIB_Transaction.InTransaction then
ParamByName('Param_1').AsWhatever := Var_1
if not prepared then
Open; (or execSQL or whatever)

I also have a generic procedure that takes a dataset as a parameter and
commits the transaction, closes the dataset, and unprepares it.

This procedure is called often - every time I am finished with the dataset.

Questions :

When should I unprepare a query or stored procedure?

Is this the best way of doing transaction control? There are exceptions -
when, for example, I need to run two or three procedures / queries and use
transaction control, they will all form part of the same transaction context.

Thanks in advance,


[Non-text portions of this message have been removed]