Subject | Re: SQLWhereItems Does not work |
---|---|
Author | Marco Menardi |
Post date | 2002-11-19T11:34:50Z |
SQLWhereItems works, you have to use it in the right way.
The ONLY place where you can use it is in OnPrepareSQL event, nowere else.
You don't have to "clear" them before use them, just start adding
conditions in the OnPrepareSQL event of the query.
Remember also that IBO tends to maximize performance avoiding
unecessary work and changes to the query, so if you "re-run" the
query, you don't have to use just open or refresh, but you have to
notify IBO that you want to change Where conditions so he has to run
OnPrepareSQL.
This is performed with the InvalidateSQL method.
So your code will be:
...
With my query do
InvalidateSQL;
if Active then refresh else open;
...
if you have also parameters that change and are assigned in the
BeforeOpen event, you have to close the query first.
...
With my query do
Close;
InvalidateSQL;
Open;
...
Not issuing InvalidateSQL makes the OnPrepareSQL be fired only the
first time the query is opened. Then IBO considers the query already
ok and does not waste time/resources in rebuilding it again.
regards
Marco Menardi
The ONLY place where you can use it is in OnPrepareSQL event, nowere else.
You don't have to "clear" them before use them, just start adding
conditions in the OnPrepareSQL event of the query.
Remember also that IBO tends to maximize performance avoiding
unecessary work and changes to the query, so if you "re-run" the
query, you don't have to use just open or refresh, but you have to
notify IBO that you want to change Where conditions so he has to run
OnPrepareSQL.
This is performed with the InvalidateSQL method.
So your code will be:
...
With my query do
InvalidateSQL;
if Active then refresh else open;
...
if you have also parameters that change and are assigned in the
BeforeOpen event, you have to close the query first.
...
With my query do
Close;
InvalidateSQL;
Open;
...
Not issuing InvalidateSQL makes the OnPrepareSQL be fired only the
first time the query is opened. Then IBO considers the query already
ok and does not waste time/resources in rebuilding it again.
regards
Marco Menardi
--- In IBObjects@y..., "radevojvodic" <rvojvodic@r...> wrote:
> Hi All,
>
> If i try to use SQLWhereItems property to change SQL of Dataset
> nothing happends. Instead I added the same statement into SQLWhere
> property with 'AND' before the exact statement and only in that case
> everything is working fine.
>
> IBO4.2 Ia, Delphi 7.