Subject Re: [IBO] TIB_Query parametrized selects and when to unprepare
Author Helen Borrie
At 11:35 AM 25-11-02 +0100, you wrote:
>Hi all,
>
>In a web application we have many TIB_Queries for parametrized select
>statements
>Now I can see two different arguments about when to do an unprepare
>
>1) Only doing an "unprepare" after the SQL has changed, might mean that when
>the request is repeated with the same SQL but different parameters we do not
>need to re-prepare and therefore we get a faster handling of the requests

Under most circumstances, you do not need to call Unprepare, and you should
not. If you change the SQL, e.g. changes that affect the Order By clause
or that alter the columns named in the WHERE clause, then you should call
InvalidateSQL. Then IBO will do the Unprepare at the right time and
minimise the amount of destruction and recreation of resources that will occur.

If you are only changing the VALUES in the WHERE parameters, not the actual
columns, then you should always leave the dataset prepared, as this does
not change the structure (metadata) of the statement.


>2) Doing always an "unprepare" after the select might mean that we prevend
>that many TIB_Queries remain claiming recources and handles in the database
>while this is not necessary

That is true. Just abide by the rule to invalidate the statement whenever
the *structure* of the dataset will change and, otherwise, either leave IBO
to take care of Prepare (as it does in the dataset classes) or include

if not Prepared then Prepare;

Helen