how to make a filter with more than 1 WHERE clause

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jasmad
Posts: 9
Joined: Wed 04 Jan 2012 21:33

how to make a filter with more than 1 WHERE clause

Post by jasmad » Tue 10 Jan 2012 22:42

Hello ,

I want to make a filter to a TIBCTable as where ID=1 AND AGE=2, but this is not supported as it shows the empty dataset, my question is ¿how can i make this kind of filters?

AndreyZ

Post by AndreyZ » Wed 11 Jan 2012 13:25

Hello,

You can use such filter in the TIBCTable component. Here are two examples (using the Filter and FilterSQL properties):
the first:

Code: Select all

IBCTable.TableName := 'tablename';
IBCTable.Open;
IBCTable.Filter := 'id=1 and age=2';
IBCTable.Filtered := True;
the second:

Code: Select all

IBCTable.FilterSQL := 'id=1 and age=2';
IBCTable.TableName := 'tablename';
IBCTable.Open;
If TIBCTable is empty after this, it means that there are no records in the table that match the filter.

jasmad
Posts: 9
Joined: Wed 04 Jan 2012 21:33

Filters

Post by jasmad » Wed 11 Jan 2012 16:07

Thanks for answering my question,

i feel that im doing something wrong becuase this:

Code: Select all

 
with tblClient do begin
            Close;
            Filtered:=False;
            Filter:='id='+inttostr(id)+' AND age=2';  
            Filtered:=True;
            Open;
end; 
do not show anything

Respects.

jasmad
Posts: 9
Joined: Wed 04 Jan 2012 21:33

Re: Filters

Post by jasmad » Wed 11 Jan 2012 20:13

jasmad wrote: i feel that im doing something wrong
I have tested the query in the database and displays many records, so the table contains records definitively. I tested also with adjusting a TIBCQuery SQL property to

Code: Select all

select * from client where ID=:idClient AND age=2
and shows me the results of the consultation and are quite

is a component problem or definitively the Filter and FilterSQL only accept one condition ?

AndreyZ

Post by AndreyZ » Thu 12 Jan 2012 09:50

I cannot reproduce the problem. Please specify the following:
- a script to create and fill your table;
- the exact version of IBDAC. You can learn it from the About sheet of TIBCConnection Editor;
- the exact version of your IDE.

jasmad
Posts: 9
Joined: Wed 04 Jan 2012 21:33

info

Post by jasmad » Thu 12 Jan 2012 14:38

the components version is 4.0.1 for Lazarus

the table is filled at design time setting the property tablename the name of the table that i need,

IDE's version is Lazarus 0.9.31

AndreyZ

Post by AndreyZ » Thu 12 Jan 2012 16:03

I cannot reproduce the problem. Please specify a script to create and fill your table.
Please note that we support only official Lazarus releases. The latest official Lazarus version is Lazarus 0.9.30.2 . Please check if the problem persists using Lazarus 0.9.30.2 .

jasmad
Posts: 9
Joined: Wed 04 Jan 2012 21:33

thanks

Post by jasmad » Thu 12 Jan 2012 17:28

AndreyZ wrote:I cannot reproduce the problem. Please specify a script to create and fill your table.
I do not use any script to fill the table, only assign values ​​in the properties window and the table is ready
Please check if the problem persists using Lazarus 0.9.30.2.
this option does not promise to me, because I work with version 0.9.31

AndreyZ

Post by AndreyZ » Fri 13 Jan 2012 09:02

I need a script to create your table, something like this:

Code: Select all

CREATE TABLE DEPT (
    DEPTNO  INTEGER PRIMARY KEY,
    DNAME   VARCHAR(14),
    LOC     VARCHAR(13)
);
Please specify a script to create your table.

jasmad
Posts: 9
Joined: Wed 04 Jan 2012 21:33

solved

Post by jasmad » Mon 23 Jan 2012 17:32

andrey thank you very much, I could solve the problem by enclosing the terms in parentheses

Code: Select all

Filter='(id=1) and (age=2)';
and works perfectly.

respects.

Post Reply