wizards/source/sfdatabases/SF_Database.xba | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
New commits: commit d07cc6706ef3b382fa16a104c97b69bc2d2365e5 Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Tue May 16 17:00:20 2023 +0200 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Wed May 17 08:53:58 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 better 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 diff --git a/wizards/source/sfdatabases/SF_Database.xba b/wizards/source/sfdatabases/SF_Database.xba index de891935be69..f93cf55d74c0 100644 --- a/wizards/source/sfdatabases/SF_Database.xba +++ b/wizards/source/sfdatabases/SF_Database.xba @@ -312,7 +312,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]" @@ -367,8 +368,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) @@ -378,7 +379,7 @@ Try: For i = 0 To lCols vResult(lRows, i) = _GetColumnValue(oResult, i + 1) Next i - .next() + bRead = .next() Loop End With