{"record":{"id":"1875ba4f59005f0a","repo":"louislam/uptime-kuma","slug":"multiple-values-were-found-expected-only-one-valu-1875ba","errorCode":null,"errorMessage":"Multiple values were found, expected only one value","messagePattern":"Multiple values were found, expected only one value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/oracledb.js","lineNumber":131,"sourceCode":"     */\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 {\n            if (connection) {\n                await connection.close();\n            }\n        }","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/oracledb.js#L113-L149","documentation":"Thrown by oracledbQuerySingleValue when the query returns more than one row. With conditions enabled the monitor needs exactly one scalar; multiple rows are ambiguous and rejected before column-count validation.","triggerScenarios":"monitor.conditions non-empty and result.rows.length > 1. Common with SELECT col FROM table without ROWNUM/ROW_LIMIT or FETCH FIRST, missing WHERE, or a join that fans out.","commonSituations":"No WHERE / no row-limit on a multi-row table; conditions enabled on a query written for the row-count path; cartesian join.","solutions":["Limit to one row: ... FETCH FIRST 1 ROWS ONLY (12c+) or wrap with ROWNUM <= 1 plus ORDER BY.","Tighten the WHERE clause so at most one row matches.","Collapse to an aggregate (MAX/MIN/SUM) returning one scalar.","Disable conditions if you only need connection/row-count semantics."],"exampleFix":"-- before: SELECT cpu_pct FROM metrics ORDER BY ts DESC;   (many rows)\n-- after:  SELECT cpu_pct FROM metrics ORDER BY ts DESC FETCH FIRST 1 ROWS ONLY;","handlingStrategy":"validation","validationCode":"async function oracleRowCount(connStr, query, user, pass) {\n  const c = await oracledb.getConnection({ connectString: connStr, user, password: pass });\n  try { return (await c.execute(query)).rows?.length ?? 0; } finally { await c.close(); }\n}","typeGuard":"function isSingleRow(r) { return r?.rows?.length === 1; }","tryCatchPattern":null,"preventionTips":["Add FETCH FIRST 1 ROWS ONLY (12c+) or ROWNUM <= 1 with a deterministic ORDER BY.","Collapse to an aggregate when you only need a scalar.","Tighten WHERE so at most one row matches; run the query in SQL Developer first."],"tags":["oracle","oracledb","sql","multiple-results","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}