Page 1 of 2

problema con xbrowser

PostPosted: Thu Apr 30, 2015 10:56 am
by mastintin
Este codigo si descomento el where falla. Alguien sabe el motivo ?
Gracias anticipadas.
Code: Select all  Expand view

cSource := "SELECT articulo.* FROM articulo"

if !Empty( nFam )
 //  cSource := cSource + " WHERE FAMILIA = 24 "
   cSource := cSource + " ORDER BY articulo.descrip"
endif

dbselectar(0)
 AdsConnect( oApli:cDbfPath , 2 )
 AdsCreateSqlStatement( "temp", 2 )
if ! AdsExecuteSqlDirect( cSource )
     ( "temp" )->( DBCloseArea() )
    pausa("error")
    RETURN nil
 endif
 sele ( "temp" )

 xbrowser temp

 close( "temp")
 

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 12:04 pm
by nageswaragunupudi
should be
xbrowser "temp"

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 1:00 pm
by russimicro
Code: Select all  Expand view
Ejp: con tablas dbf libres y ads remote server

      nError := 0
      cError := ""

      cTexCon := "SELECT art.* FROM [articulo.dat] AS art WHERE art.nexisteart > 10 ORDER BY art.cnombreart"

      SELECT 0
      IF !ADSCreateSQLStatement("INV",2)
         alert("Error sql  : " + cTexCon )
         RETURN
      ENDIF
      IF !ADSExecuteSQLDirect(cTexCon)
         alert("Error sql  : " + cTexCon )
         nError := AdsGetLastError(@cError)
         alert( "execute_sql_direct error : "+str(nError,10) )
         RETURN
      ENDIF

      select INV
      browse()

Johnson Russi
 

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 1:23 pm
by mastintin
nages ...
changed
xbrowser "temp"

if
Source := "SELECT articulo.* FROM articulo order by articulo.descrip"
is ok .

if
Source := "SELECT articulo.* FROM articulo where familia = 24 order by articulo.descrip"
if use function browse() is ok.
if use xbrowser command lauch error :

Error description: Error ADSCDX/5018 The handle given was not recognized by Advantage. Verify specified handle is open/active.

Stack Calls
===========
Called from: => ORDKEYGOTO( 0 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETRDD( 4141 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 444 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:_KEYNO( 0 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:REFRESH( 1294 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 475 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:RESIZE( 0 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1733 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 12667 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3355 )
Called from: => WNDWIDTH( 0 )
Called from: .\source\classes\CONTROL.PRG => (b)TCONTROL( 181 )
Called from: .\source\classes\CONTROL.PRG => TXBROWSE:_NWIDTH( 0 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:BRWFITSIZE( 1021 )
Called from: .\source\function\XBROWSER.PRG => FITSIZES( 273 )
Called from: .\source\function\XBROWSER.PRG => (b)XBROWSE( 242 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 703 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 893 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 289 )
Called from: .\source\function\XBROWSER.PRG => XBROWSE( 242 )
Called from: ESTADIST.PRG => YOYO( 3540 )

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 1:40 pm
by karinha

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 2:10 pm
by mastintin


No creo que sea el problema pues fallaría igualmente con cSource := "SELECT articulo.* FROM articulo" y éste no falla . :shock:
Gracias por contestar ...

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 2:23 pm
by nageswaragunupudi
You said without where clause xbrowse is working okay but you are getting error when you use where clause. Right?
I expect that without where clause the record count may be greater than 200 and with where clause the recordcount could be less than 200. Can you please check this and confirm?

If so, please look at this part of code in method SetRDD() of xbrowse.prg:
Code: Select all  Expand view
  If ( "ADS"$( ::cAlias )->( RddName() ) .or. 'ADT' $ ( ::cAlias )->( RddName() ) ) .and. ;
      ( ::cAlias )->( LastRec() ) > 200
 

Please change this line as:
Code: Select all  Expand view
  If ( "ADS"$( ::cAlias )->( RddName() ) .or. 'ADT' $ ( ::cAlias )->( RddName() ) )
 

Please see if it is working correctly after this change even with where clause.

Note: You can read in the notes below this line of code why I had to put this 200 limit. That was in 2009.

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 3:02 pm
by mastintin
nages .
Con el cambio funciona ok. :D
Pero eso afecta al código con < 200 registros. para tablas dbf "clasicas" ( use comand ) .

Tambien afecta al efecto "pijama" :?
::bClrStd := { || aClrCol[ ::KeyNo()%2 + 1 ] }
Seria bueno que el efecto pijama en vez depender del registro se pintase como fondo .

Seria deseable distinguir entre llamdas ADS por RDD y ADS con SQL .
Gracias por la solucion .

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 3:17 pm
by nageswaragunupudi
ADS por RDD y ADS con SQL

How to distinguish?
Whether a table is opened normally or through SQL, after opening the alias should function alike.

AdsRelKeyPos functions do not give reliable results. Not just for pajama effect. Sometimes we get very awkward results for small tables.

What is puzzling me is why OrdKeyNo() and OrdKeyGoTo() are failing in this case? If RDD was written correctly we should not get any error. Did you try with Harbour or xHarbour?
I suggest you try with both.
Note: I am not using ads these days.

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 3:33 pm
by mastintin
nageswaragunupudi wrote:
ADS por RDD y ADS con SQL

How to distinguish?

What is puzzling me is why OrdKeyNo() and OrdKeyGoTo() are failing in this case? If RDD was written correctly we should not get any error. Did you try with Harbour or xHarbour?
I suggest you try with both.
Note: I am not using ads these days.


Harbour.
Creo que el problema esta en :

OrdKeyGoto( n ) move record to n in active order but "temp" has no active orders .

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 3:45 pm
by mastintin
fix .... :D

IF ( ::calias )->(ordnumber()) == 0

DEFAULT ::bKeyNo := {| n | iif( n == nil,;
( ::cAlias )->( RecNo() ),;
( ::cAlias )->( DbGoto( n );
) ) },;
::bKeyCount := {|| ( ::cAlias )->( If( eof() .and. bof(), 0, ReCcount() ) ) }

else

DEFAULT ::bKeyNo := {| n | iif( n == nil,;
( ::cAlias )->( OrdKeyNo() ),;
( ::cAlias )->( OrdKeyGoto( n );
) ) },;
::bKeyCount := {|| ( ::cAlias )->( If( eof() .and. bof(), 0, OrdKeyCount() ) ) }

endif

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 3:47 pm
by nageswaragunupudi
When there is no controlling index, then ordkeygoto() should work like normal dbgoto()
That is the correct RDD implementation.
Please check this with normal DBFCDX

Re: problema con xbrowser

PostPosted: Thu Apr 30, 2015 4:41 pm
by mastintin
nageswaragunupudi wrote:When there is no controlling index, then ordkeygoto() should work like normal dbgoto()
That is the correct RDD implementation.
Please check this with normal DBFCDX


articulo.dbf table
articulo.cdx not exist

This code :

Code: Select all  Expand view

 use articulo New Via "dbfcdx"
   ordkeygoto(2)
   msginfo(FIELD->descrip)   // ok
 


this code
Code: Select all  Expand view

 use articulo New Via "adscdx"

   ordkeygoto(2)

   pausa(FIELD->descrip)  // error

 

Error occurred at: 30-04-2015, 18:36:12
Error description: Error ADSCDX/5018 The handle given was not recognized by Advantage. Verify specified handle is open/active.

Stack Calls
===========
Called from: => ORDKEYGOTO( 0 )
Called from: ESTADIST.PRG => YOYO( 3524 )
Called from: fiveh.prg => (b)BUILDMENU( 581 )

if program is set to :
rddsetdefault( "ADS" )

The dbfs not indexed breaks.

Dbgoto() is ok for 2 samples.

Re: problema con xbrowser

PostPosted: Fri May 01, 2015 3:04 am
by nageswaragunupudi
Thanks for testing. From the result of your tests we understand that OrdKeyGoTo() works with dbfcdx RDD even when there is no index and with ADS RDD it fails. When I made this change in 2009 I am sure it was working and at that time most of my applications were using ADSCDX.

If you are using Harbour we need to check with xHarbour version also.
Surprisingly it appears these functions are working:
AdsGetRelKeyPos
AdsSetRelKeyPos
AdsGetKeyCount
Theoretically, these functions also should depend on the index still they work.

Interestingly there is AdsGetKeyPos() function in ACE but no comparable function to OrdKeyGoTo()

I suggest you please continue with the change we proposed earlier.
I study both xHarbour and Harbour versions of the RDD source and also Advantage documentation and implement a dependable solution.

Re: problema con xbrowser

PostPosted: Sat May 02, 2015 12:14 pm
by nageswaragunupudi
I am making this change to SetRDD method:
Can you please check with small tables ( < 200 rows ) with and without controlling order?
Code: Select all  Expand view
  If ( "ADS"$( ::cAlias )->( RddName() ) .or. 'ADT' $ ( ::cAlias )->( RddName() ) ) // .and. ( ::cAlias )->( LastRec() ) > 200

      // Modified in FWH 9.06
      // AdsGetRelKeyPos() returns approximate position as % and when multipilied by 100 and rounded off
      // returns incorrect values occassionally on smaller  tables. OrdKeyNo() mapped to AdsKeyNo() gives reliable
      // result in such cases. For large tables OrdKeyNo() is unacceptably slow. Limit of 200 is chosen because
      // 0.5% is 1/200.


      if ( ::cAlias )->( LastRec() ) > 200

         cAdsKeyNo    := "{| n, Self | iif( n == nil, " +;
                            "Round( " + cAlias + "->( ADSGetRelKeyPos() ) * Self:nLen, 0 ), "+;
                            cAlias + "->( ADSSetRelKeyPos( n / Self:nLen ) ) ) }"
      else
         cAdsKeyNo   := "{|x,Self| " + cAlias + "->(If(x==nil,AdsKeyNo(,,1),If(Empty(OrdSetFocus()),ADSSetRelKeyPos(x/Self:nLen),OrdKeyGoTo(x))))"
      endif

      cAdsKeyCount := "{|| " + cAlias + "->( ADSKeyCount(,,1) )}"

      DEFAULT ::bKeyNo    := &cAdsKeyNo ,;
              ::bKeyCount := &cAdsKeyCount

      ::lRelyOnKeyNo      := .f.
   else