Subject | Re: [IBO] problem with sqlwhereitems |
---|---|
Author | Jason Wharton |
Post date | 2001-01-12T19:00:19Z |
I'm afraid this is a bit beyond IBO's ability to automate the SQL niceties.
You are welcome to also directly manipulate the SQL during the OnPrepareSQL
too. I suggest that you try using the macro capability I recently added.
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
You are welcome to also directly manipulate the SQL during the OnPrepareSQL
too. I suggest that you try using the macro capability I recently added.
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
----- Original Message -----
From: "Helmut Steinberger" <hs@...>
To: <IBObjects@egroups.com>
Sent: Friday, January 12, 2001 12:04 PM
Subject: [IBO] problem with sqlwhereitems
> Hi list,
>
> I have a problem using the sqlwhereitems property of ib_query. I have
> two datasets and want to select data from those two sets using
> "union".
> For example:
> The metadata of the 2 tables is:
> create table table1
> (field1 int4,
> field2 char (30),
> field3 char (20))
>
> create table table2
> (field1 int4,
> field2 char (30),
> field3 char (20))
>
> The sql property of the query is set to:
> select field1 as number, field2 as name from table1
> union
> select field1, field2 from table2
>
> In the programmcode I have to set the sqlwhereitems depending on
> values entered by the user:
>
> For example:
> ib_query1.sqlwhereitems.add('field1 > 10');
>
> This does not work like I expect it to work. I think it will be
> transfered to:
> select field1 as number, field2 as name from table1
> union
> select field1, field2 from table2
> where field1 > 10
>
> This results in that only the data of the table2 is restricted and all
> data from table1 is fetched.
>
> Correct it has to be
> select field1 as number, field2 as name from table1
> where field1 > 10
> union
> select field1, field2 from table2
> where field1 > 10
>
> How could I tell the query to make correct use of the sqlwhereitems?
>
> BTW annother question:
> For debugging cases like this, it would be very helpful, to have a
> look at the sql statement sent to the interbase server by IBO.
> For Example:
>
> procedure Tform1.query1PrepareSQL(Sender: TObject);
> begin
> query1.sqlwhereitems.addstrings ('field1 > 10');
> end;
>
> procedure Tform1.opendata;
>
> begin
> query1.sql.add ('select * from table1');
> query1.orderingitems.add ('table1_field1=field1');
> query1.orderinglinks.add ('field1=1');
> try
> query1.open;
> except
> {here I want to have a look at the sqlstatement which is created by
> the IBO and finally sent to the interbaseengine
> For the Example I think it should be:
> select * from table1
> where field1 > 10
> order by field1}
> end;
> end;
>
> thanks in advance
> Helmut
>
>
>