Page 1 of 1

[Solved] The internal Base maxRow missing?

PostPosted: Thu Nov 07, 2019 9:20 am
by arfgh
hey there friends.
I want to know if somebody knows how to programmatically detect and change the max row that Base have from loading, that are 40 rows.
Yo know when we read the row number 40, and navigate to the 41, base drive us into blank insert Row.

Of course i am looking for a way to detect that, like for example 'if form.isLast', and then force base to load other 40 records or some.

And also... of course i know the trick to do form.last, form.first. But i want to know other possible way to do it, not that trick.

Some ideas ?

Re: The internal Base maxRow messing ?

PostPosted: Fri Nov 08, 2019 9:50 pm
by UnklDonald418
There is no place where the number of rows in a database table are stored. A query like
Code: Select all   Expand viewCollapse view
SELECT COUNT (*)  FROM "SomeTableName"

will tell the database engine to calculate and report the number of rows in a table, but the database engine doesn't store that value anywhere.

Base forms use the RowSet Service to supply data to a form.
https://www.openoffice.org/api/docs/common/ref/com/sun/star/sdbc/RowSet.html
Using the MRI tool, inspect your form and it will have a property IsRowCountFinal.
https://www.openoffice.org/api/docs/common/ref/com/sun/star/ucb/ContentResultSet.html#IsRowCountFinal
The documentation indicates the value for that property remains FALSE until all of the rows in the database table have been loaded into the Base form.
The most expedient way to force IsRowCountFinal to display TRUE is to execute the method last(). For a list of all the navigation methods inherited from the ResultSet Service see
http://www.openoffice.org/api/docs/common/ref/com/sun/star/sdbc/XResultSet.html
In my tests, if a table control has 18 or fewer rows then the initial RowCount is 40, but if I resize it to hold 19 rows then the initial RowCount is 42 and with 24 lines it is 50. By increasing the number of rows on a table control to 80, the initial RowCount was 164.

If it is too much trouble for the user to use the "trick", I suppose you could write a macro that when loading a form would execute the method last() followed by first() so that IsRowCountFinal will be TRUE and RowCount will initially display the total number of rows in the table.

Re: The internal Base maxRow missing?

PostPosted: Sat Nov 09, 2019 4:09 pm
by arfgh
so UnklDonald418, isnt there a way that allow us programmatically to extend that 40 rows by default 'preloaded' by base ?
my idea was to extend other 40 when reaching the row number 40....

Re: The internal Base maxRow missing?

PostPosted: Sat Nov 09, 2019 4:32 pm
by Villeroy
Why so complicated? download/file.php?id=24806

Re: The internal Base maxRow missing?

PostPosted: Sat Nov 09, 2019 7:27 pm
by F3K Total
If you mean the fetchsize of a structural form, try:
Code: Select all   Expand viewCollapse view
Thiscomponent.DrawPage.Forms.MainForm.FetchSize = 500
to increase from 48 to 500

Re: The internal Base maxRow missing?

PostPosted: Sun Nov 10, 2019 2:11 am
by arfgh
but... i tried before to alter the 'FetchSize' and the preloaded rowcount keeps on 40 and by the way, reaching row 40 and navigating to row 41 caused empty records.... I will test it again but i am sure that i did that test....

Re: The internal Base maxRow missing?

PostPosted: Sun Nov 10, 2019 9:56 am
by F3K Total
you have to run the code in EDIT-Mode of the form, then save form and .odb, retry...

Re: The internal Base maxRow missing?

PostPosted: Sun Nov 10, 2019 1:34 pm
by arfgh
worked !!
i dont know why, but the first time i figured that the property FetchSize may be involved and i altered it, i obtained the same 40 rows as always... But now works fine...

Thx so much guys for the help :)

The internal Base maxRow missing?

PostPosted: Sun Nov 10, 2019 2:49 pm
by arfgh
just some few details more..

this way is extremelly low, 800 rows, but works fine.

Code: Select all   Expand viewCollapse view
   res = executeSQL(" SELECT COUNT (*)  FROM ""table"" ")
   res.next()
   form.fetchSize = res.getString(1)


This way works faster, but has the collateral effect calling events 'registry data change', 2 in fact.

Code: Select all   Expand viewCollapse view
   form.last
   form.first


so none of them are perfect, but with a big of control they can be used as expected...