Hi,
I can use TSQLQuery.Filter to filter on my VIEW, and I can filter all my fields, except one.
I have a field wich use 'iif()' and I can't filter on this field...
Before using a database view, I tried directly on my TSQLQuery.SQL, but the problem is the same...
So, my view works, but I Can't filter on this callulated field.
My sql view :
Create View "TestView" (
"FirstName", "LastName", "StatAge"
) AS
Select "FirstName", "LastName",
Cast(iif(CURRENT_DATE-BirthDate<18, 'Minor', 'Major') as VarChar(5)) as StatAge
from TableUsers
;
This View works well. I can do that on my TSQLQuery :
SQLQuery1.SQL.Add('Select * from TestView');
With this code, my DBGrid show all records transmitted by the view named TestView.
I can filter on FirstName, LastName, but I can't filter on StatAge ? DBGrid show empty grid with this criterea :
SQLQuery1.Filtered:=False
SQLQuery1.Filter:='"StatAge" = ''Minor''';
SQLQuery1.Filtered:=True
That's really weird because I can do my filter with a Where clause directly on the query and it works :
SQLQuery1.SQL.Add('Select * from TestView Where "StatAge"=''Minor''');
So, I'm tired with this problem... Do you have an idea ?
Thanx helphing me.