oracle: handle statements in stream

This commit is contained in:
Jan Prochazka 2024-06-01 10:49:38 +02:00
parent 0cc7a98391
commit ca0ae2084c

View File

@ -98,6 +98,8 @@ const drivers = driverBases.map(driverBase => ({
});
*/
// console.log('queryStream', sql);
if (sql.trim().toLowerCase().startsWith('select')) {
const query = client.queryStream(sql);
// const consumeStream = new Promise((resolve, reject) => {
let rowcount = 0;
@ -169,7 +171,35 @@ const drivers = driverBases.map(driverBase => ({
//resolve(rowcount);
});
//});
} else {
client.execute(sql, (err, res) => {
if (err) {
console.log('Error query', err, sql);
options.info({
message: err.message,
time: new Date(),
severity: 'error',
});
} else {
const { rowsAffected, metaData, rows } = res || {};
if (rows && metaData) {
const columns = extractOracleColumns(metaData);
options.recordset(columns);
for (const row of rows) {
options.row(zipDataRow(row, columns));
}
} else if (rowsAffected) {
options.info({
message: `${rowsAffected} rows affected`,
time: new Date(),
severity: 'info',
});
}
}
options.done();
});
}
//const numrows = await consumeStream;
//console.log('Rows selected: ' + numrows);
//client.query(query);