hana-cli version: 4.202605.1
Node: 24.14.0
DB: SAP HANA Cloud (prod-eu10)
Summary
querySimple is documented and built for SELECT, but it's also the most natural command to reach for when running ad-hoc SQL. For non-SELECT statements the CLI prints "No Query Results" (DML) or "TypeError: Cannot read properties of undefined (reading '0')" (DDL) and exits 1, even though the statement is already committed by the driver. This breaks scripts that branch on $? and confuses agents that read CLI output.
Reproduction
hana-cli querySimple --query "CREATE TABLE T1 (ID INT)" --output json --quiet
-> TypeError: Cannot read properties of undefined (reading '0') exit 1, table created
hana-cli querySimple --query "INSERT INTO T1 VALUES (1)" --output json --quiet
-> No Query Results exit 1, row inserted
hana-cli querySimple --query "SELECT * FROM T1" --output json --quiet
-> [{"ID":1}] exit 0
hana-cli querySimple --query "UPDATE T1 SET ID=2 WHERE ID=1" --output json --quiet
-> No Query Results exit 1, row updated
hana-cli querySimple --query "DELETE FROM T1 WHERE ID=2" --output json --quiet
-> No Query Results exit 1, row deleted
hana-cli querySimple --query "DROP TABLE T1" --output json --quiet
-> TypeError ... exit 1, table dropped
Root cause
bin/querySimple.js:
let results = await dbClient.execSQL(prompts.query)
if (!results[0]) {
return base.error(baseLite.bundle.getText("errNoResults"))
}
execSQL -> statement.exec() from the hdb driver returns:
- Array for SELECT
- number (rows affected) for INSERT/UPDATE/DELETE — results[0] is undefined => errNoResults, exit 1
- undefined for DDL — results[0] throws TypeError, caught and turned into exit 1
The statement is already committed inside statement.exec() before the check runs.
Suggested fix
Treat numeric / undefined results as success:
const results = await dbClient.execSQL(prompts.query)
if (typeof results === 'number') {
console.log(`Rows affected: ${results}`)
await dbClient.disconnect()
return
}
if (!Array.isArray(results) || results.length === 0) {
console.log('Statement executed (no result set).')
await dbClient.disconnect()
return
}
// existing SELECT formatting paths
...and document querySimple as supporting any single SQL statement (or alternatively add an explicit exec command for non-SELECT and keep querySimple SELECT-only — either is fine, the current state is the worst of both).
hana-cli version: 4.202605.1
Node: 24.14.0
DB: SAP HANA Cloud (prod-eu10)
Summary
querySimple is documented and built for SELECT, but it's also the most natural command to reach for when running ad-hoc SQL. For non-SELECT statements the CLI prints "No Query Results" (DML) or "TypeError: Cannot read properties of undefined (reading '0')" (DDL) and exits 1, even though the statement is already committed by the driver. This breaks scripts that branch on $? and confuses agents that read CLI output.
Reproduction
Root cause
bin/querySimple.js:
execSQL -> statement.exec() from the hdb driver returns:
The statement is already committed inside statement.exec() before the check runs.
Suggested fix
Treat numeric / undefined results as success:
...and document querySimple as supporting any single SQL statement (or alternatively add an explicit exec command for non-SELECT and keep querySimple SELECT-only — either is fine, the current state is the worst of both).