Subject | RE: Re[6]: [IBO] SQLWhereItems |
---|---|
Author | Alan McDonald |
Post date | 2006-10-10T10:47:18Z |
> Hello Alan,sorry - I'm wasting your time... that's note what I meant.
>
> There are no problems again:
>
> procedure TForm1.IB_Query1PrepareSQL(Sender: TIB_Statement);
> begin
> IB_Query1.SQLWhereItems.Add( 'DRPWFACT>0');
> IB_Query1.SQLWhereItems.Add( '(' );
> IB_Query1.SQLWhereItems.Add( '(' );
> IB_Query1.SQLWhereItems.Add( 'WCALC >0' );
> IB_Query1.SQLWhereItems.Add( 'AND' );
> IB_Query1.SQLWhereItems.Add( 'DRPLITTER = 4.8' );
> IB_Query1.SQLWhereItems.Add( ')' );
> IB_Query1.SQLWhereItems.Add( 'OR' );
> IB_Query1.SQLWhereItems.Add( '(' );
> IB_Query1.SQLWhereItems.Add( 'WCOND >0' );
> IB_Query1.SQLWhereItems.Add( 'AND' );
> IB_Query1.SQLWhereItems.Add( 'DRPHUMIDITY = 11.6' );
> IB_Query1.SQLWhereItems.Add( ')' );
> IB_Query1.SQLWhereItems.Add( ')' );
> end;
>
> Works fine...
> The same result gives:
Let's say I have several booleans I set (toggle) from a popup menu to view
certain things. Each setting leaves the popup menu item checked/not checked
so now I have a set of booleans. At the end of each setting of the menu, I
call invalidate and refresh so as to invoke prepare.
In the PrepareSQL I need to add items dependent upon the boolean values. In
this case I never end up knowing if brackets are required since I don't know
if the next value is true or not or to be OR'd. I can't setup the brackets
this way..
But never mind I've changed the logic for my purposes. I was only asking
because the help file inferred, if you like, that by sticking an OR in front
of an item, the AND would be substituted with an OR. In your case above,
these items are all AND'd. AND is implicit. OR needs to be explicit. I just
wanted it to make OR implicit if I added it separately. That's not what it
does. The brackets just protect the OR and leave it explicit.
Another way to look at it is that you can add a number of items and never
include AND anywhere but the AND will be included for you in the parsing. OR
will never be included for you if you leave it out. I wanted a trigger to
force the parsing to use OR instead of AND.
Alan