Page 1 of 1
tArrayData
Posted: Mon Aug 31, 2020 10:10 pm
by Marcelo Roggeri
Buenas noches, estoy necesitando filtrar en un tArrayData por fecha y no logro hacerlo, me da error.
Ejemplo: 1
Code: Select all
cFilter += [id_cliente=] + FW_ValToSQL(::id_contribuyente) + " "
cFilter += " .AND. " + [DTOS(cpte_fecha)>=] + ClipValue2SQL(DTOS(dFecDes))
cFilter += " .AND. " + [DTOS(cpte_fecha)<=] + ClipValue2SQL(DTOS(dFecHas))
Time from start: 0 hours 0 mins 14 secs
Error occurred at: 31/08/2020, 19:08:38
Error description: Error BASE/1003 Variable does not exist: CPTE_FECHA
Ejemplo:2
Code: Select all
cFilter += " .AND. " + [cpte_fecha>=] + FW_ValToSQL(dFecDes)
cFilter += " .AND. " + [cpte_fecha<=] + FW_ValToSQL(dFecHas)
Time from start: 0 hours 0 mins 16 secs
Error occurred at: 31/08/2020, 19:07:03
Error description: Error BASE/1076 Argument error: >=
Args:
[ 1] = D 28/08/2020
[ 2] = C 2020-08-01
Re: tArrayData
Posted: Tue Sep 01, 2020 5:59 pm
by nageswaragunupudi
When you use a TArrayData object, use filters with familiar Clipper/Harbour syntax.
Build filter expressions exactly the same way you do for DBF.
Example:
Code: Select all
cState := "NY"
dDate := STOD( "19990101" )
// cFilter := "STATE = '" + cState + "' .AND. HIREDATE >= STOD( '" + DTOS( dDate ) "' )" // This is difficult to write
// Here is a simple way
cFilter := DBF_ApplyParams( "STATE = ? .AND. HIREDATE >= ?", { cState, dDate } )
oData:SetFilter( cFilter )
Re: tArrayData
Posted: Tue Sep 01, 2020 6:40 pm
by nageswaragunupudi
Instead of this:
Code: Select all
cFilter += [id_cliente=] + FW_ValToSQL(::id_contribuyente) + " "
cFilter += " .AND. " + [DTOS(cpte_fecha)>=] + ClipValue2SQL(DTOS(dFecDes))
cFilter += " .AND. " + [DTOS(cpte_fecha)<=] + ClipValue2SQL(DTOS(dFecHas))
Use this code:
Code: Select all
cFilter := DBF_ApplyParams( "id_cliente = ? .AND. cpte_fecha >= ? .AND. cpte_fecha <= ?", { ::id_contribuyente, dFecDes, dFecHas } )
Easy to write, easy to understand and easy to maintain and most importantly, bug-free.
Note: The function DBF_ApplyParams() was first released in FWH1905.
Re: tArrayData
Posted: Tue Sep 01, 2020 7:08 pm
by Marcelo Roggeri
Buenas tardes Mr Rao
Anduvo perfecto, muy agradecido haces desde el domingo que estoy con esto pero quería agotar todas las posibilidades antes de molestar.
Corrijo el mensaje,
Me da este error usandolo asi tal cual:
cFilter := DBF_ApplyParams( "id_cliente = ? .AND. cpte_fecha >= ? .AND. cpte_fecha <= ?", { ::id_contribuyente, dFecDes, dFecHas } )
Time from start: 0 hours 0 mins 19 secs
Error occurred at: 01/09/2020, 16:34:03
Error description: Error BASE/1003 Variable does not exist: CPTE_FECHA
Saludos
Marcelo
Re: tArrayData
Posted: Tue Sep 01, 2020 8:30 pm
by Marcelo Roggeri
Fijese la fecha que me pone Mr Rao.
Re: tArrayData
Posted: Wed Sep 02, 2020 2:49 am
by nageswaragunupudi
Error description: Error BASE/1003 Variable does not exist: CPTE_FECHA
Use the field name that exists in your TArrayData object.
Re: tArrayData
Posted: Wed Sep 02, 2020 3:00 am
by Marcelo Roggeri
Asi es Mr Rao. utilizo _ que se corresponden.
Re: tArrayData
Posted: Wed Sep 02, 2020 3:55 am
by nageswaragunupudi
We will check and come back to you.
Let us also know your FWH version.
Re: tArrayData
Posted: Wed Sep 02, 2020 4:26 am
by nageswaragunupudi
Firstly, thank you for bringing this problem to our notice.
There is a bug when the same field name is used twice in the same expression.
This is fixed in the next version to be released.
If you let us know the FWH version you are using, we will also provide you the solution suitable for your version.
Re: tArrayData
Posted: Wed Sep 02, 2020 9:44 am
by nageswaragunupudi
This is the fix:
\fwh\source\function\vstrfun1.prg
function FW_ExprnAsBlock(....)
Please locate these lines: (353 to 359)
Code: Select all
if ValType( cFormat ) == "B"
AEval( aStruct, { |a,i| FW_At( c := Trim( a[ 1 ] ), @cTran, nil, nil, .t., .t., nil, ;
Eval( cFormat, i, c ) ) } )
else
AEval( aStruct, { |a,i| FW_At( Trim( a[ 1 ] ), @cTran, nil, nil, .t., .t., nil, ;
Transform( i, cFormat ) ) } )
endif
Substitute with:
Code: Select all
if ValType( cFormat ) == "B"
AEval( aStruct, { |a,i| FW_At( c := Trim( a[ 1 ] ), @cTran, nil, nil, .t., .t., nil, ;
Eval( cFormat, i, c ), .t. ) } )
else
AEval( aStruct, { |a,i| FW_At( Trim( a[ 1 ] ), @cTran, nil, nil, .t., .t., nil, ;
Transform( i, cFormat ), .t. ) } )
endif
Re: tArrayData
Posted: Wed Sep 02, 2020 1:39 pm
by Marcelo Roggeri
Mr Rao muchas gracias por tomarse el tiempo de solucionarlo.
Mi version de FWH es la July 2020
Saludos
Marcelo
Re: tArrayData
Posted: Wed Sep 02, 2020 2:22 pm
by nageswaragunupudi
Is it working for you now with this fix?
Re: tArrayData
Posted: Wed Sep 02, 2020 6:28 pm
by Marcelo Roggeri
nageswaragunupudi wrote:Is it working for you now with this fix?
Si Mr. Rao funciona a la perfección ahora
Saludos desde Argentina
Marcelo