tArrayData

Post Reply
User avatar
Marcelo Roggeri
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

tArrayData

Post 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 | Expand


          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 | Expand

         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
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post 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 | Expand


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
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post by nageswaragunupudi »

Instead of this:

Code: Select all | Expand


         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 | Expand

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
User avatar
Marcelo Roggeri
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: tArrayData

Post 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
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: tArrayData

Post by Marcelo Roggeri »

Image

Fijese la fecha que me pone Mr Rao.
FWH - Harbour - BCC7 - PellesC
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post by nageswaragunupudi »

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
User avatar
Marcelo Roggeri
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: tArrayData

Post by Marcelo Roggeri »

Asi es Mr Rao. utilizo los campos que se corresponden.
FWH - Harbour - BCC7 - PellesC
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post by nageswaragunupudi »

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post by nageswaragunupudi »

This is the fix:

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

Please locate these lines: (353 to 359)

Code: Select all | Expand

  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 | Expand

  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
User avatar
Marcelo Roggeri
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: tArrayData

Post by Marcelo Roggeri »

Mr Rao muchas gracias por tomarse el tiempo de solucionarlo.
Mi version de FWH es la July 2020
Saludos
Marcelo
FWH - Harbour - BCC7 - PellesC
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: tArrayData

Post by nageswaragunupudi »

Is it working for you now with this fix?
Regards

G. N. Rao.
Hyderabad, India
User avatar
Marcelo Roggeri
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: tArrayData

Post 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
FWH - Harbour - BCC7 - PellesC
Post Reply