Skip to content

Commit f096039

Browse files
committed
Add example of new version attributes. Update/fix LOB event examples
1 parent d7678e1 commit f096039

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

examples/blobhttp.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,20 @@ http.createServer(function(req, res){
6666

6767
lob.on(
6868
'end',
69-
function () {
69+
function()
70+
{
7071
console.log("lob.on 'end' event");
7172
res.end();
7273
});
74+
lob.on(
75+
'close',
76+
function()
77+
{
78+
console.log("lob.on 'close' event");
79+
connection.release(function(err) {
80+
if (err) console.error(err);
81+
});
82+
});
7383
lob.on(
7484
'error',
7585
function(err)

examples/selectjson.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ oracledb.getConnection(
4646
return;
4747
}
4848

49+
if (connection.oracleServerVersion < 1201000200) {
50+
console.error('This example only works with Oracle Database 12.1.0.2 or greater');
51+
process.exit(1);
52+
}
53+
4954
var data = { "userId": 1, "userName": "Chris", "location": "Australia" };
5055
var s = JSON.stringify(data);
5156

examples/selectjsonclob.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ oracledb.getConnection(
4141
{
4242
if (err) { console.error(err.message); return; }
4343

44+
if (connection.oracleServerVersion < 1201000200) {
45+
console.error('This example only works with Oracle Database 12.1.0.2 or greater');
46+
process.exit(1);
47+
}
48+
4449
doInsert(
4550
connection,
4651
JSON.stringify({ "userId": 2, "userName": "Bob", "location": "USA" }),
@@ -121,7 +126,7 @@ function doQuery(connection, cb)
121126
if (lob === null) { return cb(new Error('CLOB was NULL')); }
122127
lob.setEncoding('utf8'); // set the encoding so we get a 'string' not a 'buffer'
123128
lob.on('data', function(chunk) { clob += chunk; });
124-
lob.on('end', function() { return cb(null, JSON.parse(clob)); });
129+
lob.on('close', function() { return cb(null, JSON.parse(clob)); });
125130
lob.on('error', function(err) { return cb(err); });
126131
});
127132
}

0 commit comments

Comments
 (0)