Subject [IBO] Re: Refreshing parameterised IB_Query when params change
Author Marco Menardi <mmenaz@lycosmail.com>
--- In IBObjects@yahoogroups.com, Lester Caine <lester@l...> wrote:
> > In addition, in the b) situation, when you use OnParamSQL event, you
> > have to invalidate the query to make this event work. All this "low
> > level" IBO is confusing for beginners / intermediate, and often is
> > error prone (you lately introduce OnParamSQL, and all your "refresh"
> > becomes useless). So, for b), I asked for a "strong refresh" that
>

Writing mistake: not OnParamSQL but OnPrepareSQL :(

> Marco - I think the problem here is that you are trying to
> do things that already happen automatically, and so your
> attempts to make them work are being hampered by other actions.

Oh, not exactly. I've designed my app following one assumption and, I
now suppose, misunderstood advice: put param assignment in BeforeOpen
events.
So I adapted my program to the tool (IBO), and now, since I've
discovered that IBO works different than expected (by me), I'm trying
to adapt the tool to my program <g>

>
> When you change a Parameter, RefreshOnParamChange will allow
> the query to update itself. This will result in a
> OnDataChange event which allows other changes to be managed,
> or alternatively, if the detail tables are linked via
> 'MasterSource' and 'MasterParamLinks', (along with
> RefreshOnParamChange on the detail queries), then there is
> no need to be playing with the low level stuff at all.

I know "the old way" ;) I've changed the logic to take advantage of
the BeforeOpen event as a central place for assignments, so a simple
"refresh" everywere in my program would have updated the dataset and,
in that event, the parameters. Now I've to revert back, or learn some
other design strategy.

>
> While I could see a use for OnPrepareSQL, I have never used
> it, along with 95% of the rest of the events. If the
> database design is tidy, there should be no need to play
> with anything other than the basic IBO functions.

The problem is that if you can't avoid NULL in your fields/tables,
there is the situation where you have to test a field against some
user provided values that can include null.
Unfortunatly, if you try in code something like:
where (:myid is null) or (customer_id = :myid)
you have an exception raisen.
The only way for manage this situation is modify the where part of the
query, and the best place in in OnPrepareSQL event.
From an simmetric point of view, I think that a similar event for
param assignment should be provided...
regards
Marco Menardi