{"record":{"id":"c002c3324ff7ef31","repo":"louislam/uptime-kuma","slug":"query-returned-no-results-c002c3","errorCode":null,"errorMessage":"Query returned no results","messagePattern":"Query returned no results","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/oracledb.js","lineNumber":127,"sourceCode":"     * @param {string} query The query to execute\n     * @param {string} username Oracle DB username\n     * @param {string} password Oracle DB password\n     * @returns {Promise<any>} Single value from the first column of the first row\n     */\n    async oracledbQuerySingleValue(connectionString, query, username, password) {\n        let connection;\n        try {\n            connection = await oracledb.getConnection({\n                connectString: connectionString,\n                user: username,\n                password: password,\n            });\n            const result = await connection.execute(query, [], {\n                outFormat: oracledb.OUT_FORMAT_OBJECT,\n            });\n\n            if (!result.rows || result.rows.length === 0) {\n                throw new Error(\"Query returned no results\");\n            }\n\n            if (result.rows.length > 1) {\n                throw new Error(\"Multiple values were found, expected only one value\");\n            }\n\n            const firstRow = result.rows[0];\n            const columnNames = Object.keys(firstRow);\n\n            if (columnNames.length > 1) {\n                throw new Error(\"Multiple columns were found, expected only one value\");\n            }\n\n            return firstRow[columnNames[0]];\n        } catch (error) {\n            log.debug(this.name, \"Error caught in the query execution.\", error.message);\n            throw error;\n        } finally {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/oracledb.js#L109-L145","documentation":"Thrown by oracledbQuerySingleValue when result.rows is absent or empty. Only reached when conditions are enabled, since the monitor then expects a scalar to feed the condition evaluator. An empty result means there is no value to compare.","triggerScenarios":"monitor.conditions non-empty, connection.execute(query) resolves with result.rows.length === 0 (or null rows). Typical when a WHERE filters all rows, the object is in another schema, or the query targets the wrong PDB.","commonSituations":"WHERE too restrictive; table/view renamed; querying the CDB root for PDB-local data; environment missing the expected reference row; conditions enabled on a row-count-style query.","solutions":["Run the query in SQL Developer/SQLcl as the monitor user and confirm exactly one row returns.","If no-row is legitimate, rewrite with a guaranteed scalar: SELECT NVL((SELECT ... ),0) FROM dual.","Loosen/fix the WHERE clause and ensure correct schema/PDB.","Disable conditions if only connection/row-count semantics are needed."],"exampleFix":"-- before: SELECT balance FROM accounts WHERE id=:id;   (id missing -> 0 rows)\n-- after:  SELECT NVL((SELECT balance FROM accounts WHERE id=:id), -1) FROM dual;","handlingStrategy":"validation","validationCode":"async function assertOracleSingleValue(connStr, query, user, pass) {\n  const c = await oracledb.getConnection({ connectString: connStr, user, password: pass });\n  try { const r = await c.execute(query, [], { outFormat: oracledb.OUT_FORMAT_OBJECT });\n    if (!r.rows || r.rows.length === 0) throw new Error('0 rows');\n    if (r.rows.length > 1) throw new Error('>1 row');\n    if (Object.keys(r.rows[0]).length > 1) throw new Error('>1 column');\n    return r.rows[0][Object.keys(r.rows[0])[0]]; }\n  finally { await c.close(); }\n}","typeGuard":"function isSingleValueRows(r) { return r?.rows?.length === 1 && Object.keys(r.rows[0]).length === 1; }","tryCatchPattern":null,"preventionTips":["Before enabling conditions, run the query and assert it returns 1 row x 1 column.","Use NVL((SELECT ...),0) FROM dual so the query always returns a scalar.","Confirm schema/PDB context; disable conditions if only connection checks are needed."],"tags":["oracle","oracledb","sql","empty-result","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}