xBrowse with SQLRDD

pcordonet
Posts: 110
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

xBrowse with SQLRDD

Post by pcordonet »

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

Re: xBrowse with SQLRDD

Post by nageswaragunupudi »

>>
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
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse with SQLRDD

Post by PeterHarmes »

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
pcordonet
Posts: 110
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

Re: xBrowse with SQLRDD

Post by pcordonet »

Thank you, for your answer.

I'll try substitute these functions !

Pere Cordonet
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: xBrowse with SQLRDD

Post by nageswaragunupudi »

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
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse with SQLRDD

Post by PeterHarmes »

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)
pcordonet
Posts: 110
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

Re: xBrowse with SQLRDD

Post by pcordonet »

I need some time for implement this source.

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

Thank you.
Pere Cordoent :D
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse with SQLRDD

Post by PeterHarmes »

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

Re: xBrowse with SQLRDD

Post by nageswaragunupudi »

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

Re: xBrowse with SQLRDD

Post by nageswaragunupudi »

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
pcordonet
Posts: 110
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

Re: xBrowse with SQLRDD

Post by pcordonet »

A very slow elementary functions could be:

Code: Select all

Function SR_OrdkeyCount(xOrder)
Local nItem:= 0, nRecno:= Recno()
Local nOO:= OrdNumber()
OrdSetFocus( xOrder )

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

OrdSetFocus(nOO)
DbGoto(nRecno)

Return nItem
 

Code: Select all

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
User avatar
Alfredo Arteaga
Posts: 326
Joined: Sun Oct 09, 2005 5:22 pm
Location: Mexico
Contact:

Re: xBrowse with SQLRDD

Post by Alfredo Arteaga »

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: xBrowse with SQLRDD

Post by nageswaragunupudi »

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: Select all

// 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
pcordonet
Posts: 110
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

Re: xBrowse with SQLRDD

Post by pcordonet »

I have finally changed bKeyCount and bKeyno codeblock

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

Code: Select all

@ <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.
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse with SQLRDD

Post by PeterHarmes »

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!!
Post Reply