Page 1 of 1

Complex Search on dbf from an array

PostPosted: Wed Feb 13, 2019 12:38 pm
by Silvio.Falconi
if I have an array with 16 fields ( for a sample 30 records)

and I wish see if I have allready the same record on a dbf

and if found assign on array a check if there is allready a record into dbf

How I must make ?

sample :

I create a price list for the June ( aData array)

Image

I wish Know if the user allready insert each record on tariffe.dbf database

How I must make

I wish check if the fields tipo,idelemento,servizio,settori,giorni,mese are the same
as column 2,3,7,8,9 and 10,

I could index the tariffe.dbf on tipo+idelemento

I must use set filter?

Re: Complex Search on dbf from an array

PostPosted: Wed Feb 13, 2019 3:08 pm
by ukoenig
Silvio,

selected customer in DBF2 checked if customer exist in DBF1
( can be a array or fields, from gets ... )

Image

No :Setfilter() :!:

to be filtered
cName := oCust2:Last + oCust2:First

filterd in DBF1 with 450 records
oCust1:ORDSCOPE( 0, NIL ) // reset
oCust1:ORDSCOPE( 1, NIL )

oCust1:ORDSCOPE(0, cName ) // filter
oCust1:ORDSCOPE(1, cName )
oCust1:DBGOTOP()


regards
Uwe :D

Re: Complex Search on dbf from an array

PostPosted: Wed Feb 13, 2019 3:39 pm
by Silvio.Falconi
But i have more fields to check
On sql there is the query and on dbf?

Re: Complex Search on dbf from an array

PostPosted: Wed Feb 13, 2019 3:47 pm
by ukoenig
Just define a string with any condition to be filtered

if I have an array with 16 fields ( for a sample 30 records)
and I wish see if I have allready the same record on a dbf


cName := oCust2:Last + oCust2:First + :?: + :?:

regards
Uwe :D

Re: Complex Search on dbf from an array

PostPosted: Wed Feb 13, 2019 9:02 pm
by Silvio.Falconi
But i have a hard problem..
The procedure must found a price on dbf having only :
1.Datein and dateout to determine the mounth
2. Number of days
3. Type of produc
4. Code of the product
5. Letter of sector
And the dbf can be much big

Re: Complex Search on dbf from an array

PostPosted: Wed Feb 13, 2019 10:42 pm
by ukoenig
Silvio,

I think it will be no problem to replace
Customer and custom2 with 2 other files
and different fields for a new test
You just have to define a main-index where the filter belongs to
( I thinks it is product :?:
Check it out and have a look at test No. 8
of the new download ( have a look at the new image ).

1.Datein and dateout to determine the mounth
2. Number of days
3. Type of produc
4. Code of the product
5. Letter of sector


Just copy TDATAB7.prg to TDATAB8.prg ( empty test )
There replace FUNCTION DATABASE7() with FUNCTION DATABASE8()
and You will have a new test
don't make changes to the original test in case You need some informations.
FUNCTION DATABASE8() is the last empty test. Maybe we still need some more.

regards
Uwe :D

Re: Complex Search on dbf from an array

PostPosted: Mon Feb 18, 2019 4:55 pm
by Silvio.Falconi
I resolved with a easy setfilter

I had difficulty finding the way how to pass the values contained in the tips

Local cFilter := "trim(Tipo) == '" + cTipo +;
"' .and. alltrim(str(giorni))== '" + alltrim(str(nGiorni)) +;
"' .and. idelemento== '"+cidelemento+;
"' .and. settore== '" +cSettore+;
"' .and. alltrim(idlistino)== '" +clistino+"'"

oTariffePrezzi:= TTariffe():new()
oTariffePrezzi:setFilter( cFilter)
oTariffePrezzi:gotop()

nPrezzo:= oTariffePrezzi:totale