Hello to EveryOne
How can make a filter condition on TDatabase Class?
Any help would be apreciate.
Many Thanks
Regards
Dionisis
How can make a Filter condition on TDatabase Class?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Dionisis,
You may implement and try this new Class TDataBase Method SetFilter():
METHOD SetFilter( bCondition, cCondition ) INLINE If( bCondition != nil, ( ::nArea )->dbSetFilter( bCondition, cCondition ), ( ::nArea )->dbClearFilter() )
Example:
oDbf:SetFilter( { || oDbf:Load(), oDbf:Age > 20 }, "Age > 20" )
You may implement and try this new Class TDataBase Method SetFilter():
METHOD SetFilter( bCondition, cCondition ) INLINE If( bCondition != nil, ( ::nArea )->dbSetFilter( bCondition, cCondition ), ( ::nArea )->dbClearFilter() )
Example:
oDbf:SetFilter( { || oDbf:Load(), oDbf:Age > 20 }, "Age > 20" )
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Hi again Antonio.
The code pass from the compiler but when implemented on a real database i get a mass.
As an example i have one database named Transacs.dbf that contain a field named MDAY and is of type date . When assigning a filter like
I get the number of 10 records. The record number of the whole database, without filtering.
What i make wrong!!!
Many thanks for your patience.
Regards
Dionisis
The code pass from the compiler but when implemented on a real database i get a mass.
As an example i have one database named Transacs.dbf that contain a field named MDAY and is of type date . When assigning a filter like
Code: Select all
odbINSTALL:SetFilter({||Month(odbInstall:MDAY)=Month(Date())},;
"Month(odbInstall:Mday)=Month(Date())")
MsgInfo (STR(odbInstall:Reccount())+" Records Fouds")
What i make wrong!!!
Many thanks for your patience.
Regards
Dionisis
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Dionisis,
You have to reload the database object from the codeblock:
You have to reload the database object from the codeblock:
Code: Select all
odbINSTALL:SetFilter({||odbINSTALL:Load(), Month(odbInstall:MDAY)=Month(Date())},;
"Month(odbInstall:Mday)=Month(Date())")
MsgInfo (STR(odbInstall:Reccount())+" Records Fouds")
Antonio
This method works but it is usefull with Browsers and not to namipulate directly the aBuffer or to count the length of a filetered database.
What i mean is that after applying the method SetFilter(). The lenght of database not varies. I get the same Reccout() with or without the SetFilter() method. Nothing happens the only defference i noticed is when i call the Browse() function it displays the correct portion of filtered database.
Those are my observations for the SetFilter() method. I giveup and look for another approach.I know that is difficult but i hope to deal with this difficult situation.
Regards and goodnight
Dionisis
This method works but it is usefull with Browsers and not to namipulate directly the aBuffer or to count the length of a filetered database.
What i mean is that after applying the method SetFilter(). The lenght of database not varies. I get the same Reccout() with or without the SetFilter() method. Nothing happens the only defference i noticed is when i call the Browse() function it displays the correct portion of filtered database.
Those are my observations for the SetFilter() method. I giveup and look for another approach.I know that is difficult but i hope to deal with this difficult situation.
Regards and goodnight
Dionisis
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: