FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour tArrayData
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
tArrayData
Posted: Mon Aug 31, 2020 10:10 PM
Buenas noches, estoy necesitando filtrar en un tArrayData por fecha y no logro hacerlo, me da error.
Ejemplo: 1
Code (fw): Select all Collapse
          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 (fw): Select all Collapse
          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
FWH - Harbour - BCC7 - PellesC
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Tue Sep 01, 2020 05:59 PM
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 (fw): Select all Collapse
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 )
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Tue Sep 01, 2020 06:40 PM
Instead of this:
Code (fw): Select all Collapse
         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 (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: tArrayData
Posted: Tue Sep 01, 2020 07:08 PM

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

FWH - Harbour - BCC7 - PellesC
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: tArrayData
Posted: Tue Sep 01, 2020 08:30 PM


Fijese la fecha que me pone Mr Rao.
FWH - Harbour - BCC7 - PellesC
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Wed Sep 02, 2020 02:49 AM
Error description: Error BASE/1003 Variable does not exist: CPTE_FECHA

Use the field name that exists in your TArrayData object.
Regards



G. N. Rao.

Hyderabad, India
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: tArrayData
Posted: Wed Sep 02, 2020 03:00 AM

Asi es Mr Rao. utilizo los campos que se corresponden.

FWH - Harbour - BCC7 - PellesC
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Wed Sep 02, 2020 03:55 AM

We will check and come back to you.
Let us also know your FWH version.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Wed Sep 02, 2020 04:26 AM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Wed Sep 02, 2020 09:44 AM
This is the fix:

\fwh\source\function\vstrfun1.prg
function FW_ExprnAsBlock(....)

Please locate these lines: (353 to 359)
Code (fw): Select all Collapse
   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 (fw): Select all Collapse
   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
Regards



G. N. Rao.

Hyderabad, India
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: tArrayData
Posted: Wed Sep 02, 2020 01:39 PM

Mr Rao muchas gracias por tomarse el tiempo de solucionarlo.
Mi version de FWH es la July 2020
Saludos
Marcelo

FWH - Harbour - BCC7 - PellesC
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tArrayData
Posted: Wed Sep 02, 2020 02:22 PM

Is it working for you now with this fix?

Regards



G. N. Rao.

Hyderabad, India
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: tArrayData
Posted: Wed Sep 02, 2020 06:28 PM
nageswaragunupudi wrote:Is it working for you now with this fix?

Si Mr. Rao funciona a la perfección ahora
Saludos desde Argentina
Marcelo
FWH - Harbour - BCC7 - PellesC

Continue the discussion