FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse with SQLRDD
Posts: 111
Joined: Sat Jan 30, 2010 08:35 AM

xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 10:12 AM

Hi to all,

Anyone can put a sample with xBrowse with SQLRDD.

If it's posible, define only two fields of file with many fields.

Thank you.
Pere Cordonet

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 12:03 PM

>>
If it's posible, define only two fields of file with many fields.
>>
Yes.
@ .. XBROWSE ......
COLUMNS "field1name", "field2name" ;
<other clauses>

I have not used SQLRDD. But I have gone through the manual quickly. It appears SQLRDD does not support OrdKeyCount() and OrdKeyNo(). I am not sure if I am right. There could be some issues with SQLRDD.

Regards



G. N. Rao.

Hyderabad, India
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 02:11 PM

I use xBrowse with SQLRDD and can confirm that it works - there are issues with OrdKeyCount() & OrdKeyNo() as nageswaragunupudi says - the only area i have found to be a problem is the "hot key" seeking in a browse.

Regards,

Pete

Posts: 111
Joined: Sat Jan 30, 2010 08:35 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 02:28 PM

Thank you, for your answer.

I'll try substitute these functions !

Pere Cordonet

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 03:10 PM
PeterHarmes wrote:I use xBrowse with SQLRDD and can confirm that it works - there are issues with OrdKeyCount() & OrdKeyNo() as nageswaragunupudi says - the only area i have found to be a problem is the "hot key" seeking in a browse.

Regards,

Pete

If this is the case, I would suggest that after creating xbrowse, we need to override these codeblocks:

oBrw:bKeyNo := { |n| If( n == nil, (oBrw:cAlias)->( RecNo() ), (oBrw:cAlias)->(DbGoTo(n)) }
oBrw:bKeyCount := { || (oBrw:cAlias)->( LastRec() ) }

Better to retain the other default codeblocks as created by xbrowse without disturbing them.

I presume RecNo(), DbGoTo(n) and LastRec() are supported. If they have other names, they can be substituted.

Still there could be occasional issues because in SQLRDD, the recno can be higher than the recordcount.

May I know how DbSeek() works or how we can simulate that behavior?
( Xbrowse implements incremental seek for ADO recordsets using ADO Find method)
Regards



G. N. Rao.

Hyderabad, India
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 03:42 PM

Recno() & Dbgoto exist and work in the normal way - i'm not too sure about Lastrec() as i don't use it - i will do some tests tomorrow to see if this works.

Dbseek() also works in the same way (although the softseek parameter seems a bit buggy)

Posts: 111
Joined: Sat Jan 30, 2010 08:35 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 03:46 PM

I need some time for implement this source.

When i have a result, i'll comment this.

Thank you.
Pere Cordoent :D

Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 03:51 PM

Tests on Lastrec

Opened orders table - has 7621 rows

Lastrec() returns 7628 which is the largest value in the column sr_recno (where the record number/row number) is stored.

In the xHarbour Reference - Lastrec() should return the number of records, so I would say this function does not work properly under SQLRDD

Pete

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 04:27 PM

Mr. Peter Harmes,

I understand.

For xbrowse to properly work,
1) oBrw:bKeyCount should be a codeblock which should return the total number of rows.
So what function do you advise for this codeblock?

2) oBrw:bKeyNo := { |n| If( n == nil, < serial number of the row >, < goto the n'th row from top> ) }
For bKeyNo codeblock, what functions do you advise?

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 04:34 PM
Opened orders table - has 7621 rows

Lastrec() returns 7628 which is the largest value in the column sr_recno (where the record number/row number) is stored.

What I understood from what little i read the documentation is this. SR_RecNo is maintained like an autoincrement number. When no records are deleted, and no filters or scopes are set ( using where clause or otherwise ) Max( SR_RecNo) -->LastRec() correctly represents the total rows. But when some records are deleted, number of rows is less than LastRec,i.e. Max(SR_RecNo). And most of the times we read and browse only a subset of the total table using some kind of scope or filter or where clause.
In such cases we need to have reliable way to know (i) number of rows, (ii) serial number of the row and (iii) to go to a row with a given serial number in the subset being browsed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 111
Joined: Sat Jan 30, 2010 08:35 AM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 04:55 PM
A very slow elementary functions could be:

Code (fw): Select all Collapse
Function SR_OrdkeyCount(xOrder)
Local nItem:= 0, nRecno:= Recno()
Local nOO:= OrdNumber()
OrdSetFocus( xOrder )

DbGotop()
DbEval({|| nItem++ })

OrdSetFocus(nOO)
DbGoto(nRecno)

Return nItem


Code (fw): Select all Collapse
Function SR_OrdkeyNo(xOrder)
Local nItem:= 0, nRecno:= Recno(),nKey:= 0
Local nOO:= OrdNumber()
OrdSetFocus( xOrder )

DbGotop()
DbEval({|| nItem++,Iif(Recno() == nRecno, nKey:= nItem,nil) },,{|| Empty(nKey) } )
Iif(Empty(nKey),nKey:= nItem,nil)
OrdSetFocus(nOO)
DbGoto(nRecno)

Return nKey


Require that if the procedure would be correct.
Thank you.
Pere Cordonet
Posts: 326
Joined: Sun Oct 09, 2005 05:22 PM

Re: xBrowse with SQLRDD

Posted: Wed Apr 28, 2010 06:28 PM
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse with SQLRDD

Posted: Thu Apr 29, 2010 01:52 AM
Mr. Peter Harmes

If you are using xBrowse with SQLRDD successfully, can you please tell us how are you building codeblocks for oBrw:bKeyNo and oBrw:bKeyCount ?

From what I understand from the above postings, I think the codeblocks I posted earlier should give reasonable results for browsing full tables and where there are no or few deleted records.

In other cases, I think of an alternative approach, which takes some setup time but xBrowse will work correctly.
Code (fw): Select all Collapse
// Initially
   aRows := {}
   (cAlias)->( DbGoTop() )
   (cAlias)->( DbEval( {|| AAdd( aRows, RecNo() ) } )
   (cAlias)->( DbGoTop() )
// normal xbrowse code   
   @ <r>, <c> XBROWSE oBrw COLUMNS .....<other clauses> ..;
        ALIAS cAlias ROWS aRows  // Please note the clause ROWS aRows
Regards



G. N. Rao.

Hyderabad, India
Posts: 111
Joined: Sat Jan 30, 2010 08:35 AM

Re: xBrowse with SQLRDD

Posted: Thu Apr 29, 2010 09:42 AM
I have finally changed bKeyCount and bKeyno codeblock

It works quite well (with a table with 200 entries)

Code (fw): Select all Collapse
@ <r>, <c> XBROWSE oBrw
oBrw:SetRDD (. f.. f.)
oBrw:bKeyNo      := {|| ( ::cAlias )->( SR_OrdkeyNo() )       }
oBrw:bKeyCount := {|| ( ::cAlias )->( SR_OrdkeyCount() )   }


Thanks for all information to finally works fine, not is the best solution for a long tables, but this function will be much better if xharbour will be written in sqlrdd lib.

Thanks to all
Pere Cordonet

Note: Sorry for my english, it's very poor.
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM

Re: xBrowse with SQLRDD

Posted: Thu Apr 29, 2010 10:04 AM

I dont build a code block for bKeyno, but for bKeycount (where i use it) - i do a SQL count for the number of records that meet the criteria and apply this to a variable and to bKeycount.

By the looks of things on the data we have used, the standard xBrowse functionality works fine!!