Subject | Re[6]: [IBO] SQLWhereItems |
---|---|
Author | Ramil |
Post date | 2006-10-10T10:01:56Z |
Hello Alan,
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:
procedure TForm1.IB_Query1PrepareSQL(Sender: TIB_Statement);
var
S: String;
begin
S := '(WCALC >0 AND DRPLITTER = 4.8)';
S := '(' + S + ' OR (WCOND >0 AND DRPHUMIDITY = 11.6)'+ ')';
S := 'DRPWFACT>0 AND ' + S;
IB_Query1.SQLWhereItems.Add( S );
// S = 'DRPWFACT>0 AND ((WCALC >0 AND DRPLITTER = 4.8)
// OR (WCOND >0 AND DRPHUMIDITY = 11.6))'
end;
Your task of the PROGRAMMER - to build CORRECT LOGIC EXPRESSION
and to not miss necessary brackets.
I think It's possible for any unknown number of items.
And it should do the application, not IBO.
If you are confused with features of SQLWhereItems use directly
SQLWhere or entirely processing SQL as answered others.
But I do not see difficulties especially for the second example.
--
Best regards,
Ramil R. Khabibullin khabibr@...
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:
procedure TForm1.IB_Query1PrepareSQL(Sender: TIB_Statement);
var
S: String;
begin
S := '(WCALC >0 AND DRPLITTER = 4.8)';
S := '(' + S + ' OR (WCOND >0 AND DRPHUMIDITY = 11.6)'+ ')';
S := 'DRPWFACT>0 AND ' + S;
IB_Query1.SQLWhereItems.Add( S );
// S = 'DRPWFACT>0 AND ((WCALC >0 AND DRPLITTER = 4.8)
// OR (WCOND >0 AND DRPHUMIDITY = 11.6))'
end;
Your task of the PROGRAMMER - to build CORRECT LOGIC EXPRESSION
and to not miss necessary brackets.
I think It's possible for any unknown number of items.
And it should do the application, not IBO.
If you are confused with features of SQLWhereItems use directly
SQLWhere or entirely processing SQL as answered others.
But I do not see difficulties especially for the second example.
--
Best regards,
Ramil R. Khabibullin khabibr@...
>
>
>
>
>
>> Hello Alan,
>>
>> > tried that - you get a syntax error at OR and the monitor
>> shows it parsed as
>> > "AND OR" on that item
>> > as I say - they help file says if you add a single OR it will
>> not use AND
>> > but use the OR but it doesn't - it sticks an AND in anyway.
>>
>> Are you sure?
>> I had successfully tested with my example:
>>
>> procedure TForm1.IB_Query1PrepareSQL(Sender: TIB_Statement);
>> begin
>> IB_Query1.SQLWhereItems.Add( '(' ); // !!! Don't omit!
>> IB_Query1.SQLWhereItems.Add( 'DRPLITTER = 4.8' );
>> IB_Query1.SQLWhereItems.Add( 'OR' );
>> IB_Query1.SQLWhereItems.Add( 'DRPHUMIDITY = 11.6' );
>> IB_Query1.SQLWhereItems.Add( ')' ); // !!! Don't omit!
>> end;
>>
>> There are no problems here!
>> I get syntax error at OR only if I remove brackets.
>>
>> --
>> Best regards,
>> Ramil R. Khabibullin khabibr@...
>
> That's fine if you are adding 2 items together. If I am adding an unknown
> number of items to the SQLWhereItems and I want to AND some of them and OR
> some others. This won't work. Try to add ONE item into the SQLWhereItems
> which is OR'd amongst several which are AND'd.
> Alan
>