@WrRan
2016-11-24T05:50:32.000000Z
字数 954
阅读 1115
node-oracledb
The node-oracledb add-on for Node.js powers high performance Oracle Database applications.
This document shows how to use node-oracledb. The API reference is in
sections 2 - 7 and the user guide in subsequent sections.
For how to install node-oracledb, see INSTALL.
var oracledb = require('oracledb');
oracledb.getConnection(
{
user : "hr",
password : "welcome",
connectString : "localhost/XE"
},
function(err, connection)
{
if (err) {
console.error(err.message);
return;
}
connection.execute(
"SELECT department_id, department_name " +
"FROM departments " +
"WHERE manager_id < :id",
[110], // bind value for :id
function(err, result)
{
if (err) {
console.error(err.message);
return;
}
console.log(result.rows);
});
});
With Oracle's sample HR schema, the output is:
[ [ 60, 'IT' ], [ 90, 'Executive' ], [ 100, 'Finance' ] ]
Node-oracledb can also use Promises.
There are more node-oracledb examples in the
examples
directory.
Scripts to create Oracle's sample schemas can be found at
github.com/oracle/db-sample-schemas.