tArrayData

tArrayData

Postby Marcelo Roggeri » 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: Select all  Expand view

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

Re: tArrayData

Postby nageswaragunupudi » Tue Sep 01, 2020 5: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: Select all  Expand view

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: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

Postby nageswaragunupudi » Tue Sep 01, 2020 6:40 pm

Instead of this:
Code: Select all  Expand view

         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 view
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
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

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

Re: tArrayData

Postby Marcelo Roggeri » Tue Sep 01, 2020 8:30 pm

Image

Fijese la fecha que me pone Mr Rao.
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: tArrayData

Postby nageswaragunupudi » Wed Sep 02, 2020 2: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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

Postby Marcelo Roggeri » Wed Sep 02, 2020 3:00 am

Asi es Mr Rao. utilizo los campos que se corresponden.
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: tArrayData

Postby nageswaragunupudi » Wed Sep 02, 2020 3:55 am

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: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

Postby nageswaragunupudi » Wed Sep 02, 2020 4: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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

Postby nageswaragunupudi » Wed Sep 02, 2020 9:44 am

This is the fix:

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

Please locate these lines: (353 to 359)
Code: Select all  Expand view
  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 view
  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
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

Postby Marcelo Roggeri » Wed Sep 02, 2020 1: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
User avatar
Marcelo Roggeri
 
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: tArrayData

Postby nageswaragunupudi » Wed Sep 02, 2020 2:22 pm

Is it working for you now with this fix?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tArrayData

Postby Marcelo Roggeri » Wed Sep 02, 2020 6: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
User avatar
Marcelo Roggeri
 
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests