Subject | Prepared and unprepared |
---|---|
Author | Tim Ledgerwood |
Post date | 2003-06-30T06:36:52Z |
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
begin
if not TIB_Transaction.InTransaction then
TIB_Transaction.Commit;
if active then close;
if not TIB_Transaction.InTransaction then
TIB_Transaction.StartTransaction;
ParamByName('Param_1').AsWhatever := Var_1
if not prepared then
Prepare;
Open; (or execSQL or whatever)
First;
end;
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,
Tim
[Non-text portions of this message have been removed]
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
begin
if not TIB_Transaction.InTransaction then
TIB_Transaction.Commit;
if active then close;
if not TIB_Transaction.InTransaction then
TIB_Transaction.StartTransaction;
ParamByName('Param_1').AsWhatever := Var_1
if not prepared then
Prepare;
Open; (or execSQL or whatever)
First;
end;
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,
Tim
[Non-text portions of this message have been removed]