Created attachment 187156 [details] Sample document Steps to reproduce 1 have base document with 1.1 with a table 1.1.1 with content KategorieID | KategorieName 1 | red 2. have macro Sub Main GlobalScope.BasicLibraries.loadLibrary("ScriptForge") DIM oDoc AS OBJECT : oDoc = CreateScriptService("SFDocuments.Document",ThisDatabaseDocument) DIM oDB AS OBJECT : oDB = oDoc.GetDatabase() Dim queryResults as Variant queryResults = oDB.GetRows("SELECT * FROM [Kategorien] WHERE [KategorieName] = 'red'") ' works as expected queryResults = oDB.GetRows("SELECT * FROM [Kategorien] WHERE [KategorieName] = 'green'") ' crash End Sub 3. Run macro Expected behavior GetRows returns array of records found. An empty array, if no records found Actual behavior GetRows creates a popup window complaining about a crash, if no records found / empty result set
Created attachment 187157 [details] screenshot
Reproduced with document. Jean-Pierre: you are probably interested in this. Arch Linux 64-bit, X11 Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community Build ID: d2756dbd9b11bdfbf1d576381b8f9846a6fb7070 CPU threads: 8; OS: Linux 6.3; UI render: default; VCL: kf5 (cairo+xcb) Locale: fi-FI (fi_FI.UTF-8); UI: en-US Calc: threaded Built on 15 May 2023
The complete expected bheviour is: when there is no data returned by the query, - - either GetRows()returns an empty array, when Header := False - or GetRows() returns an array with a single row containing the column names only Indeed, in the example given, 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() executions on the resultset. A patch will be provided to correct the error. Thanks for having reported the issue.
Jean-Pierre Ledure committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/d07cc6706ef3b382fa16a104c97b69bc2d2365e5 ScriptForge - database.GetRows() tdf#155204 error when no data It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Jean-Pierre Ledure committed a patch related to this issue. It has been pushed to "libreoffice-7-5": https://git.libreoffice.org/core/commit/2840a8e139f9e6766fe291512f6a42b3d72371f6 ScriptForge - database.GetRows() tdf#155204 error when no data It will be available in 7.5.4. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
*** Bug 156238 has been marked as a duplicate of this bug. ***