Subject RE: [IBO] TIB_Query
Author Jason Wharton
> With a TIB_Query I have next statement:
>
> "Select a.id, a.name from master_table where a.code = 1"
>
> When I need to perform another select with the same query like
>
> "Select a.id, a.name from master_table where a.code = 4"
>
> Is better to close/open with new SQL entry or doing next commands:
>
> SQL->Clear();
> SQL->Add("Select a.id, a.name from master_table where a.code = 4")
> SQL->Refresh();
>
> Is better use Params or create the where condition and pass as a
> unique SQL command like example?
>
> I want to minime overload.

If you are looking to minimize overhead here is what you should do:

MyQuery.SQL.Text := 'select a.id, a.name from master_table where a.code =
:code';
MyQuery.Prepare;
MyQuery.ParamByName( 'CODE' ).AsInteger := 1;
MyQuery.Open;

<do whatever>

MyQuery.Close;
MyQuery.ParamByName( 'CODE' ).AsInteger := 4;
MyQuery.Open;

<do some more stuff>

MyQuery.Unprepare;


What you had above would force the query to be unprepared when you modified
the SQL property. I have an internal OnChange event that triggers if you
touch this property because if you do then I need to send the statement to
the server again in order to have it be prepared.

Jason Wharton
www.ibobjects.com