wizards/source/sfdatabases/SF_Database.xba |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 2840a8e139f9e6766fe291512f6a42b3d72371f6
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Tue May 16 17:00:20 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed May 17 12:47:47 2023 +0200

    ScriptForge - database.GetRows() tdf#155204 error when no data
    
    The complete expected bheviour is:
    when there is no data returned by the query,
    - either GetRows() returns an empty array, (Header := False)
    - or GetRows() returns an array with a single
    row containing the column names only (Header := True)
    
    In the example given in the bug report,
    GetRows() gives an unexpected error.
    
    Actually the "end-of-file" status is tested
    with the isAfterLast() indicator.
    It seems preferable to rely on the Boolean value
    returned by the first() and next() methods applied
    on the resultset.
    
    Change-Id: Ibe97dbbcb03d45ebb9184fab2733abe4e04963a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151844
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jenkins
    (cherry picked from commit d07cc6706ef3b382fa16a104c97b69bc2d2365e5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151781
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/wizards/source/sfdatabases/SF_Database.xba 
b/wizards/source/sfdatabases/SF_Database.xba
index f0dec87c294e..4297fbc7b09a 100644
--- a/wizards/source/sfdatabases/SF_Database.xba
+++ b/wizards/source/sfdatabases/SF_Database.xba
@@ -310,7 +310,8 @@ Dim sSql As String                          &apos;  SQL 
statement
 Dim bDirect                                            &apos;  Alias of 
DirectSQL
 Dim lCols As Long                              &apos;  Number of columns
 Dim lRows As Long                              &apos;  Number of rows
-Dim oColumns As Object
+Dim oColumns As Object                 &apos;  Collection of 
com.sun.star.sdb.ODataColumn
+Dim bRead As Boolean                   &apos;  When True, next record has been 
read successfully
 Dim i As Long
 Const cstThisSub = &quot;SFDatabases.Database.GetRows&quot;
 Const cstSubArgs = &quot;SQLCommand, [DirectSQL=False], [Header=False], 
[MaxRows=0]&quot;
@@ -365,8 +366,8 @@ Try:
                End If
 
        &apos;  Load data
-               .first()
-               Do While Not .isAfterLast() And (MaxRows = 0 Or lRows &lt; 
MaxRows - 1)
+               bRead = .first()
+               Do While bRead And (MaxRows = 0 Or lRows &lt; MaxRows - 1)
                        lRows = lRows + 1
                        If lRows = 0 Then
                                ReDim vResult(0 To lRows, 0 To lCols)
@@ -376,7 +377,7 @@ Try:
                        For i = 0 To lCols
                                vResult(lRows, i) = _GetColumnValue(oResult, i 
+ 1)
                        Next i
-                       .next()
+                       bRead = .next()
                Loop
        End With
        

Reply via email to