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 ' SQL statement Dim bDirect ' Alias of DirectSQL Dim lCols As Long ' Number of columns Dim lRows As Long ' Number of rows -Dim oColumns As Object +Dim oColumns As Object ' Collection of com.sun.star.sdb.ODataColumn +Dim bRead As Boolean ' When True, next record has been read successfully Dim i As Long Const cstThisSub = "SFDatabases.Database.GetRows" Const cstSubArgs = "SQLCommand, [DirectSQL=False], [Header=False], [MaxRows=0]" @@ -365,8 +366,8 @@ Try: End If ' Load data - .first() - Do While Not .isAfterLast() And (MaxRows = 0 Or lRows < MaxRows - 1) + bRead = .first() + Do While bRead And (MaxRows = 0 Or lRows < 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