Subject | Re: [IBO] problem with sqlwhereitems |
---|---|
Author | Svein Erling Tysvær |
Post date | 2001-01-15T08:28:30Z |
I must be missing something here. I didn't know that an ambiguous call like
ib_query1.sqlwhereitems.add('field1 > 10'); was supposed to work at all,
but would expect
ib_query1.sqlwhereitems.add('table1.field1 > 10');
ib_query1.sqlwhereitems.add('table2.field1 > 10');
to work as you intend it to. Are you saying that this doesn't work?
Set
At 20:04 12.01.2001 +0100, you wrote:
ib_query1.sqlwhereitems.add('field1 > 10'); was supposed to work at all,
but would expect
ib_query1.sqlwhereitems.add('table1.field1 > 10');
ib_query1.sqlwhereitems.add('table2.field1 > 10');
to work as you intend it to. Are you saying that this doesn't work?
Set
At 20:04 12.01.2001 +0100, you wrote:
>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
>
>
>
>