problem with dbsetfilter

problem with dbsetfilter

Postby Silvio.Falconi » Sun Oct 18, 2015 4: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


Image


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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6796
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with dbsetfilter

Postby AHF » Sun Oct 18, 2015 5:59 pm

Maybe trying INDEX ON giorno TAG ASS1 or AS->( OrdScope(0, { || dtoc(date()) }))
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: problem with dbsetfilter

Postby FranciscoA » Sun Oct 18, 2015 6: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
User avatar
FranciscoA
 
Posts: 2111
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: problem with dbsetfilter

Postby Gale FORd » Sun Oct 18, 2015 7: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()) })
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: problem with dbsetfilter

Postby AHF » Sun Oct 18, 2015 7: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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: problem with dbsetfilter

Postby Gale FORd » Mon Oct 19, 2015 2: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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: problem with dbsetfilter

Postby Silvio.Falconi » Mon Oct 19, 2015 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6796
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with dbsetfilter

Postby Silvio.Falconi » Mon Oct 19, 2015 9:02 am

but wich is the best ? ( between run ok)

SELECT AS
AS->(DbSetOrder(1))
AS->( OrdScope(0, { || dtos(date()) }))
AS->( OrdScope(1, { || dtos(date()) }) )
AS->(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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6796
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with dbsetfilter

Postby ukoenig » Mon Oct 19, 2015 9: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
Last edited by ukoenig on Mon Oct 19, 2015 10:56 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: problem with dbsetfilter

Postby Silvio.Falconi » Mon Oct 19, 2015 9: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6796
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 21 guests

cron