xBrowse & SQLRDD

Re: xBrowse & SQLRDD

Postby nageswaragunupudi » Thu Oct 06, 2011 3:11 pm

If you are using the latest XBrowse, for SQLRDD, we are using RecNo() and DbGoTo() functions only both for bBookMark and bKeyNo().
We are not using OrdKeyNo().
We expect SQLRDD to be perfectly reliable with RecNo() and GoTo() functions even if used in quick succession many times.
Regards

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

Re: xBrowse & SQLRDD

Postby PeterHarmes » Thu Oct 06, 2011 3:25 pm

But doesnt that mean that the browse must be in recno() order?

I might be reading the select method wrong, but doesnt it skip(-1) if the recno() of the second record selected with the shift is less than the 1st?
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby PeterHarmes » Thu Oct 06, 2011 3:48 pm

I've modified the select routine, but this only works if the index is indexed on a unique key:

See the section where nOperation == 3

Code: Select all  Expand view


METHOD Select( nOperation ) CLASS TXBrowse

   local uBook, uCurRow, uOldRow, uTemp
   local aTemp
   local nAt, nLen
   local lRefresh
   Local cStIndexKey  := ""
   Local cEndIndexKey := ""

   if .not. ::lMultiSelect // ::nMarqueeStyle != MARQSTYLE_HIGHLROWMS .and. ::nMarqueeStyle != MARQSTYLE_HIGHLWIN7
      return nil
   endif

   DEFAULT nOperation := 1
   do case
   case nOperation ==   0 // delete all
      if Len( ::aSelected ) == 1 .and.  Eval( ::bBookMark ) == ::aSelected[ 1 ]
         lRefresh := .f.
      else
         lRefresh := .t.
      endif
      ::aSelected   := {}

      if ! Empty( ::nSaveMarq )
         ::nMarqueeStyle   := ::nSaveMarq
         ::nSaveMarq       := nil
      endif

      if lRefresh
         // ::lRefreshOnlyData := .t.
         ::GetDC()
         ::Super:Refresh( .t. ) // ::Paint()
         ::ReleaseDC()
      endif

   case nOperation == 1 .or. ( Len( ::aSelected ) == 0 .and. nOperation != 4 )// Add current
      uBook := Eval( ::bBookMark )
      nAt   := Ascan( ::aSelected, uBook )
      if nAt == 0
         Aadd( ::aSelected, uBook )
         ::DrawLine( .t. )
      endif

   case nOperation == 2 // Swap key (Ctrl+LClick)
      uBook := Eval( ::bBookMark )
      nAt   := Ascan( ::aSelected, uBook )
      if nAt > 0
         ::DrawLine( .f. )
         ::aSelected[ nAt ] := Atail( ::aSelected )
         Asize( ::aSelected, Len( ::aSelected ) - 1 )
      else
         Aadd( ::aSelected, Eval( ::bBookMark ))
         ::DrawLine( .t. )
      endif

   case nOperation == 3 // Shift & lclick
      cEndIndexKey := &( ( ::cAlias )->(IndexKey()) )
      uBook   := Eval( ::bBookMark )
      uCurRow := ::KeyNo()
      Eval( ::bBookMark,  Atail( ::aSelected ) )
      uOldRow := ::KeyNo()
      cStIndexKey := &( ( ::cAlias )->(IndexKey()) )
      if uOldRow != uCurRow
         ::aSelected := { Atail( ::aSelected ) }
         if IF( ( ::cAlias )->( RddName() ) == "SQLRDD", cEndIndexKey > cStIndexKey, uCurRow > uOldRow)
            CursorWait()
            do while ( uTemp := Eval( ::bBookMark ) ) != uBook .and. ! ::Eof()
               If Ascan( ::aSelected, uTemp ) == 0
                  Aadd( ::aSelected, uTemp )
               Endif
               ::Skip( 1 )          // Eval( ::bSkip, 1 )
            enddo
            CursorArrow()
         else
            CursorWait()
            do while ( uTemp := Eval( ::bBookMark ) ) != uBook .and. ! ::Bof()
               If Ascan( ::aSelected, uTemp ) == 0
                  Aadd( ::aSelected, uTemp )
               endif
               ::Skip( -1 )         // Eval( ::bSkip, -1 )
            enddo
            CursorArrow()
         endif
         Aadd( ::aSelected, uBook )
         Eval( ::bBookMark, uBook )
         // ::lRefreshOnlyData := .t.
         ::GetDC()
         ::Paint()
         ::ReleaseDC()

      else
         Eval( ::bBookMark, uBook )
      endif

   case nOperation == 4 // Select all
      uBook       := Eval( ::bBookMark )
      ::aSelected := Array( ::KeyCount() )
      nAt         := 1
      nLen        := ::nLen
      aTemp       := ::aSelected
      CursorWait()
      Eval( ::bGotop )
      do while nAt <= nLen //.and. !Eval( ::bEof )
         aTemp[ nAt++ ] := Eval( ::bBookMark )
         ::Skip( 1 )             //Eval( ::bSkip, 1 )
      enddo
      Eval( ::bBookMark, uBook )
      CursorArrow()
      // ::lRefreshOnlyData := .t.
      ::GetDC()
      ::Paint()
      ::ReleaseDC()

   case nOperation == 5 // Swap key (Shift + GoDown or GoUp)
      uCurRow := ::KeyNo()
      nAt     := Ascan( ::aSelected, uCurRow )
      uBook   := Eval( ::bBookMark )
      if nAt == 1 .and. len( ::aSelected ) == 1
         return nil
      elseif nAt == 0
         Aadd( ::aSelected, uBook )
         ::DrawLine( .t. )
      else
         if nAt != len( ::aSelected )
            Asize( ::aSelected, Len( ::aSelected ) - 1 )
            ::Refresh()
         endif
      endif

   end case

return nil

 
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby nageswaragunupudi » Thu Oct 06, 2011 3:57 pm

Eval( oBrw:bBookMark ) returns the RecNo()
Eval( oBrw:bBookMark, n ) executes( DBGOTO( n ), RECNO() )


But doesnt that mean that the browse must be in recno() order?

Yes.
Any problem?
Regards

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

Re: xBrowse & SQLRDD

Postby PeterHarmes » Fri Oct 07, 2011 8:02 am

I would say that was a pretty big problem wouldnt you?
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby nageswaragunupudi » Fri Oct 07, 2011 8:31 am

XBrowse needs to know the following:

What are the functions for:
1. GoTop
2. GoBottom
3. Skip n Rows
4. What is the function to know the row number in natural order
( this is normally RecNo() in RDDs )
5. What is the function which xBrowse can use to go to the row number in natural order.
( This is normally DBGOTO( n ) )
6. If you can order the rows in any other other than the natural order:-
(a) What is the function to know the serial number of the row in that order? ( in many RDD;s this OrdKeyNo() )
and
(b) What is the function XBrowse can use to position to a partiual serial number in an ordered table. ( in many RDDs this is OrdKeyGoTo( n ) )
7. What is the function to know the total number of records?

Now, if you let me know what are the functions SQLRDD provides for 6(a) and 6(b) then we can make the codeblocks when the table is not in natural order.
Regards

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

Re: xBrowse & SQLRDD

Postby PeterHarmes » Fri Oct 07, 2011 8:45 am

This is the problem I think, those functions are not available under SQLRDD.

The changes you have made in the recent version for SQLRDD are nearly perfect so I think they can stay in xBrowse, it's just the part where it checks if the second click is higher or lower in the list is the problem. The only work around I can see is the change I made a few posts earlier. This would suit my needs as I would ensure that my index contain unique keys.

I think we cant go any further without OrdKeyNo() functions, so I dont mind making those minor changes I made in the earlier post each time I update FW, unless other SQLRDD users require these changes and maybe we can incorporate it in somehow?

What do you think?

Best regards,

Pete

(Thank you for your time in looking at this problem - we have always told our SQL customers that shift selecting was not possible and they have accepted this, so the work you have done and the change I made will be appreciated by our users)
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby nageswaragunupudi » Fri Oct 07, 2011 9:15 am

Still I don't like you to give up. I agree I do not about SQLRDD but if you look around you may find the answers.
Regards

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

Re: xBrowse & SQLRDD

Postby PeterHarmes » Fri Oct 07, 2011 9:26 am

I can remember seeing on the SQLRDD forum someone asking if these functions were available and was told that it would be impossible make these work - I may ask the question again to see if they've had an idea how to implement this.

For me, it's not giving up, shift & select now works with SQLRDD in an xbrowse in my application (selfish I know)

I will let you know if I get any reply from xHarbour about the functions.

Thanks

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby Enrico Maria Giordano » Fri Oct 07, 2011 10:02 am

Using ADO, OrdKey() can be replaced by oRs:AbsolutePosition and OrdKeyGoTo( n ) by oRs:AbsolutePosition = n.

I don't know if it can be of any help.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: xBrowse & SQLRDD

Postby PeterHarmes » Fri Oct 07, 2011 10:05 am

I have posted a message so lets see if xHarbour.com are helpfull!
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby nageswaragunupudi » Fri Oct 07, 2011 4:57 pm

Enrico Maria Giordano wrote:Using ADO, OrdKey() can be replaced by oRs:AbsolutePosition and OrdKeyGoTo( n ) by oRs:AbsolutePosition = n.

I don't know if it can be of any help.

EMG

You are right. That is how XBrowse's SetAdo() works.

But I think SQLRDD does not use ADO. Instead it uses the native libraries of the respective RDMS.

I also do not *think* SQLRDD does sorting of any datasets/recordsets in memory, like ADO does. Instead I *guess* it may be reading from the source again with appropriate "ORDER BY <sortcolumn>" clause. I may be wrong. But if my guess is correct, the table view should always be in the order or RecNo().
Regards

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

Re: xBrowse & SQLRDD

Postby Blessed » Sat Oct 08, 2011 9:18 pm

Hi

I try "bBookMark" and is not stable, when I browse the list items I repeat, my customers complain that the application is confusing, I'm just excuses, I hope that at some point has a solution.

Code: Select all  Expand view
oxBrw:bKeyNo = oxBrw:bBookMark


In fact, I followed the post by Peter both here and in xHarbour.
On both sides are said to be 100% compatible and is not so, what I see is that they are solid products that are complementary and should work more closely is this type of case.
I think everyone benefits: FWH, SQLRDD of xHarbour.com, like us who buy your products.

Regards
Oscar A. Martinez
http://www.multisofthn.com
Honduras, Centro America
xHarbour Enterprise 1.2.2, Fivewin 13.06
User avatar
Blessed
 
Posts: 243
Joined: Wed Sep 19, 2007 4:32 pm
Location: Honduras, C.A.

Re: xBrowse & SQLRDD

Postby PeterHarmes » Mon Oct 10, 2011 8:25 am

Unfortunately, I've found more problems - If I browse a SQL table that i've put a scope on, the browse displays the first record at the bottom of the browse and looks like there are 2 selected records. If I page up/page down, the browse resets and looks good. If i then move the mouse cursor outside of the browse, the browse corrupts again (first record at the bottom of the browse).

I never had these problems with the previous version of xbrowse I used (10.06)

Any ideas where I can start to look to see where this problem has come from?

Regards,

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse & SQLRDD

Postby PeterHarmes » Mon Oct 10, 2011 8:34 am

If I comment out the SQLRDD section of the SETRDD method, it fixes the duplicate record problem I reported in my last post, however if I move my mouse outside of the browse, the current selected record jumps to the top of the browse.

I can confirm that this is a SQLRDD only problem, I ran the same code on a DBF and it works fine. So it seems as if there is a section of the code that needs commenting out for SQLRDD???

*UPDATE*

I think the problem is the MouseLeave Method, If I make the following changes, it seems to work:

Code: Select all  Expand view


METHOD MouseLeave( nRow, nCol, nFlags ) CLASS TXBrowse

   ::lPressed = .f.

   if ( ::cAlias )->( RddName() ) <> "SQLRDD"
       ::Refresh()
   endif

return nil

 


I'm going to try and get the shift key selection workig with SQLRDD and I will post my solution (if it works) :lol:
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 49 guests