node-oracledb version 1.2 node v0.12.7
Selects work as expected. For Updates and Inserts, Though we get rowsAffected: 1, the insert or Update is not effected.
var oracledb = require('oracledb');
oracledb.getConnection(
{
user: "HRTest",
password: "********",
connectString: "localhost/XE"
},
function (err, connection) {
if (err) {
console.error(err.message);
return;
}
connection.execute(
"UPDATE TBCUSTOMERDetails set FIRSTNAME=:fn WHERE id=:id ",
{fn: 'new name', id: 1},
function (err, result) {
if (err) {
console.error(err.message);
return;
}
console.log(result);
connection.release(
function (err) {
if (err) {
console.error(err.message);
throw(err);
}
else console.log("released connection");
}); // end release
}); // end function
});</code></pre>
Thanks daivrz, committing fixed the issue, the default on node-oracle is false.
var oracledb = require('oracledb');
oracledb.autoCommit = true;
The native settings for the oracledb driver set the autoCommit to false. You can either set the autoCommit to true at the beggining of the script or call it in the connection.execute() callback.
connection.execute(
"UPDATE TBCUSTOMERDetails set FIRSTNAME=:fn WHERE id=:id ",
{fn: 'new name', id: 1},
{autoCommit: true},
function (err, result) {
if (err) {
console.error(err.message);
return;
}
console.log(result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With