FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour problem with dbsetfilter
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

problem with dbsetfilter

Posted: Sun Oct 18, 2015 04:15 PM
I made

SELECT AS
AS->(DbSetOrder(1))
AS->(DbSetFilter( {|| AS->Giorno=date() }, ))
AS->(DbGoTop())

and I wish show only the record have as->giorno = date() it run ok

but sometimes it show also one record with another date





the archive is index on
INDEX ON dtoc(giorno) TAG ASS1

any solution please ?

i tried also with
SELECT AS
AS->(DbSetOrder(1))
AS->( OrdScope(0, { || date() }))
AS->( OrdScope(1, { || date() }) )
AS->(DbGoTop())

but not run on
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM

Re: problem with dbsetfilter

Posted: Sun Oct 18, 2015 05:59 PM

Maybe trying INDEX ON giorno TAG ASS1 or AS->( OrdScope(0, { || dtoc(date()) }))

Regards

Antonio H Ferreira
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM

Re: problem with dbsetfilter

Posted: Sun Oct 18, 2015 06:51 PM
DbSetFilter( <bFilter>, [<cFilter>] ) --> NIL

Arguments
<bFilter>
A code block containing the filter expression. The expression must yield a logical value.
<cFilter>
The filter expression in form of a character string. Return
The return value is always NIL.
Description
The DbFilter() function defines a filter condition for the current work area in form of the code block <bFilter>. All records in the work area where the filter condition yields .F. (false) are ignored during database navigation. As a result, these records become invisible and are filtered.

Although the second parameter <cFilter> is optional, it is recommended to specify the filter condition a second time as a character string. Otherwise, the DbFilter() function cannot obtain the filter condition and returns a null string (""), despite of a filter condition being active.
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM

Re: problem with dbsetfilter

Posted: Sun Oct 18, 2015 07:16 PM

I recommend you use dtos() in your index, not dtoc()
Then for scope you can use
AS->( OrdScope(0, { || dtos(date()) }))
AS->( OrdScope(1, { || dtos(date()) })

Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM

Re: problem with dbsetfilter

Posted: Sun Oct 18, 2015 07:55 PM

Doesn t index sort correctly a date field ?
Must we convert it to dtos ?

The value type should match both index key and scope and should error if not.

Regards

Antonio H Ferreira
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM

Re: problem with dbsetfilter

Posted: Mon Oct 19, 2015 02:15 AM

His index was using dtoc() which is not very good to sort/index with. If you are going to index on date converted to character string then dtos() is the correct function.

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: problem with dbsetfilter

Posted: Mon Oct 19, 2015 08:58 AM
perhaps I found the problem

after I open the database and make the filter

I call the old record where the archive is stop

if nRecNo < AS->(LastRec()) .AND. nRecno != 0
AS->(DbGoTo(nRecno)) <------------------------------------the error
else
AS->(DbGoTop())
endif


on nRecNo I save on ( inifile) the record and it then make the error because if the user open today on 20.10.2015 and the user have close on 16.10.2015 the procedure show the records on 20.10.2015 (by filter) and the show the record save as old used.

If i ren these lines it run good with

SELECT AS
AS->(DbSetOrder(1))
AS->(DbSetFilter( {|| AS->Giorno=date() }, ))
AS->(DbGoTop())


probable I make a mistake on the oldest modification...
sorry...
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: problem with dbsetfilter

Posted: Mon Oct 19, 2015 09:02 AM

but wich is the best ? ( between run ok)

                    SELECT AS
                     AS-&gt;(DbSetOrder(1))
                     AS-&gt;( OrdScope(0, { || dtos(date()) }))
                     AS-&gt;( OrdScope(1, { || dtos(date()) }) )
                     AS-&gt;(DbGoTop())

or

SELECT AS
AS->(DbSetOrder(1))
AS->(DbSetFilter( {|| AS->Giorno=date() }, ))
AS->(DbGoTop())

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: problem with dbsetfilter

Posted: Mon Oct 19, 2015 09:32 AM

Silvio,

DBSETFILETR is much slower in case there are many records,
because the filter ckecks from start- to the end of file.
A filter doesn't need a INDEX. That is the difference of the usage.
With just a few records there will be no difference.

best regards
Uwe

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: problem with dbsetfilter

Posted: Mon Oct 19, 2015 09:05 PM

FOR EACH DAY PERHAPS 5/6 RECORDS

THINK AFTER A MONTH PERHAPS 150/160 RECORDS

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion