xBrowse with SQLRDD

xBrowse with SQLRDD

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

Re: xBrowse with SQLRDD

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

Re: xBrowse with SQLRDD

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

Re: xBrowse with SQLRDD

Postby pcordonet » Wed Apr 28, 2010 2:28 pm

Thank you, for your answer.

I'll try substitute these functions !

Pere Cordonet
pcordonet
 
Posts: 111
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

Re: xBrowse with SQLRDD

Postby nageswaragunupudi » Wed Apr 28, 2010 3: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
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse with SQLRDD

Postby PeterHarmes » Wed Apr 28, 2010 3: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)
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: xBrowse with SQLRDD

Postby pcordonet » Wed Apr 28, 2010 3:46 pm

I need some time for implement this source.

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

Thank you.
Pere Cordoent :D
pcordonet
 
Posts: 111
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona

Re: xBrowse with SQLRDD

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

Re: xBrowse with SQLRDD

Postby nageswaragunupudi » Wed Apr 28, 2010 4: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
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse with SQLRDD

Postby nageswaragunupudi » Wed Apr 28, 2010 4: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
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse with SQLRDD

Postby pcordonet » Wed Apr 28, 2010 4:55 pm

A very slow elementary functions could be:

Code: Select all  Expand view

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  Expand view

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

Re: xBrowse with SQLRDD

Postby Alfredo Arteaga » Wed Apr 28, 2010 6:28 pm

User avatar
Alfredo Arteaga
 
Posts: 326
Joined: Sun Oct 09, 2005 5:22 pm
Location: Mexico

Re: xBrowse with SQLRDD

Postby nageswaragunupudi » Thu Apr 29, 2010 1: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: Select all  Expand view

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

Re: xBrowse with SQLRDD

Postby pcordonet » Thu Apr 29, 2010 9:42 am

I have finally changed bKeyCount and bKeyno codeblock

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

Code: Select all  Expand view

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

Re: xBrowse with SQLRDD

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], jmartial, Marc Venken and 109 guests