Skip to content

Commit

Permalink
Merged master into db2a-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmabupt committed Dec 27, 2018
2 parents 4bc34ee + 59439d2 commit 2fac131
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 31 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# idb-connector changelog

## 1.1.6

- Added alias shorthands for use during bindParams()
- Added Add checks for value, io type and bindIndicator during bindParams()
- Return null instead of empty [] when output params are not present, during execute()
- Updated examples, API reference and test cases

## 1.1.5

- Refined docs and trace for scrollable cursor
Expand Down
61 changes: 31 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,65 @@ Then you can _require_ in your code, as shown below.

## Example 1: Fectching data using the exec() API
```js
const db = require('idb-connector');
const {dbconn, dbstmt} = require('idb-connector');
const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
const dbconn = new db.dbconn();
dbconn.conn("*LOCAL");
const stmt = new db.dbstmt(dbconn);
const connection = new dbconn();
connection.conn("*LOCAL");
const statement = new dbstmt(connection);

stmt.exec(sSql, (x) => {
statement.exec(sSql, (x) => {
console.log("%s", JSON.stringify(x));
stmt.close();
dbconn.disconn();
dbconn.close();
statement.close();
connection.disconn();
connection.close();
});
```

## Example 2: Fectching data using the fetchAll() API
```js
const db = require('idb-connector');
const {dbconn, dbstmt} = require('idb-connector');
const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
const dbconn = new db.dbconn();
dbconn.conn("*LOCAL");
const stmt = new db.dbstmt(dbconn);
const connection = new dbconn();
connection.conn("*LOCAL");
const statement = new dbstmt(connection);

stmt.prepare(sSql, () => {
stmt.execute(() => {
stmt.fetchAll((x) => {
statement.prepare(sSql, () => {
statement.execute(() => {
statement.fetchAll((x) => {
console.log("%s", JSON.stringify(x));
stmt.close();
statement.close();
});
});
});
```

## Example 3: Call stored procedures
```js
const db = require('idb-connector');
const idb = require('idb-connector'),
{dbconn, dbstmt, IN, OUT, CHAR, CLOB} = idb;
const sql = "CALL QXMLSERV.iPLUG512K(?,?,?,?)";
const dbconn = new db.dbconn();
dbconn.conn("*LOCAL");
const stmt = new db.dbstmt(dbconn);
const connection = new dbconn();
connection.conn("*LOCAL");
const statement = new dbstmt(connection);

const ipc = "*NA";
const ctl = "*here";
const xmlIn = "<xmlservice><sh>system 'wrksbs'</sh></xmlservice>";
const xmlOut = "";

stmt.prepare(sql, () => {
stmt.bindParam([
[ipc, db.SQL_PARAM_INPUT, db.BIND_STRING],
[ctl, db.SQL_PARAM_INPUT, db.BIND_STRING],
[xmlIn, db.SQL_PARAM_INPUT, db.BIND_CLOB],
[xmlOut, db.SQL_PARAM_OUTPUT, db.BIND_CLOB]
statement.prepare(sql, () => {
statement.bindParam([
[ipc, IN, CHAR],
[ctl, IN, CHAR],
[xmlIn, IN, CLOB],
[xmlOut, OUT, CLOB]
], () => {
stmt.execute((out) => { // 'out' is an array of output params
statement.execute((out) => { // 'out' is an array of output params
for(let i = 0; i < out.length; i++)
console.log(out[i]);
stmt.close();
dbconn.disconn();
dbconn.close();
statement.close();
connection.disconn();
connection.close();
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "idb-connector",
"version": "1.1.5",
"version": "1.1.6",
"description": "A Node.js DB2 driver for IBM i",
"main": "lib/db2a.js",
"directories": {
Expand Down

0 comments on commit 2fac131

Please sign in to comment.