[关闭]
@WrRan 2016-11-24T05:50:32.000000Z 字数 954 阅读 1115

node-oracledb

Introduction

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.

Example: Simple SELECT statement in Node.js with Callbacks

  1. var oracledb = require('oracledb');
  2. oracledb.getConnection(
  3. {
  4. user : "hr",
  5. password : "welcome",
  6. connectString : "localhost/XE"
  7. },
  8. function(err, connection)
  9. {
  10. if (err) {
  11. console.error(err.message);
  12. return;
  13. }
  14. connection.execute(
  15. "SELECT department_id, department_name " +
  16. "FROM departments " +
  17. "WHERE manager_id < :id",
  18. [110], // bind value for :id
  19. function(err, result)
  20. {
  21. if (err) {
  22. console.error(err.message);
  23. return;
  24. }
  25. console.log(result.rows);
  26. });
  27. });

With Oracle's sample HR schema, the output is:

  1. [ [ 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.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注