How to use oracle transaction with node.js
I trying to use either 'persist' or 'oracle' to perform transactions in the oracle database through node.js program, i am not sure if there is a feasibility to do that required process or its not working for me. Kindly help!
You mention that it may no be working for you but you didn't provide a code sample? The documentation currently doesn't have an oracle example but I can assure you it works just fine with oracle as I have been using it with oracle for a couple weeks now in production.
I have forked this repo and working on a few changes that I hope will be accepted into master once I finish them. In the meantime at my forked page you can view an expanded database.json file that shows how to declare oracle with and without using TNS names.(my fork: http://github.com/ioneyed/node-persist )
If that doesnt solve your problem then please provide a gist/sample of your implementation so we can resolve your issue. Stating its just not working isn't a good way to get a resolution.
Thanks for your response. I have added my simple code below for your perusal. Program is not executing the loop tx.rollback or tx.commit. Kind help if there is asynchronous flow or syntax issues.
var persist = require('persist');
var connectData = { driver:"oracle", hostname: "localhost", port: 1521, database: "xe", // System ID (SID) user: "tsw", password: "ts" };
persist.connect(connectData, function(err, connection){ if(err) { return console.error('could not connect to oracle', err); } else { connection.tx(function(err,tx){ connection.runSql("update emp set employee_name = :1 where employee_id = :2",["RaguSachin",320923], function(err, result){ if(err) { console.log('rollback'); tx.rollback(function(err,result) { if(err) { console.log('error in rollback'); connection.close(); } else { console.log('rollback success'); } }); } else { console.log('No error'); tx.commit(function(err,result) { if(err) { console.log('error in cvommit'); connection.close(); } else { console.log('commit success');
}
});
}
});
});
}
});