Skip to content

Commit 1d289cd

Browse files
committed
Show node-oracledb 4.2 lastRowid output in example
1 parent a87a9aa commit 1d289cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/insert1.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. */
1+
/* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. */
22

33
/******************************************************************************
44
*
@@ -23,6 +23,7 @@
2323
*
2424
* To insert many records at a time see em_insert1.js
2525
*
26+
* This example requires node-oracledb 4.2 or later.
2627
* This example uses Node 8's async/await syntax.
2728
*
2829
*****************************************************************************/
@@ -66,20 +67,23 @@ async function run() {
6667
{ id : {val: 1 }, nm : {val: 'Chris'} }
6768
);
6869
console.log("Rows inserted: " + result.rowsAffected); // 1
70+
console.log("ROWID of new row: " + result.lastRowid);
6971

7072
// 'bind by position' syntax
7173
result = await connection.execute(
7274
`INSERT INTO no_tab1 VALUES (:id, :nm)`,
7375
[2, 'Alison']
7476
);
7577
console.log("Rows inserted: " + result.rowsAffected); // 1
78+
console.log("ROWID of new row: " + result.lastRowid);
7679

7780
result = await connection.execute(
7881
`UPDATE no_tab1 SET name = :nm`,
7982
['Bambi'],
8083
{ autoCommit: true } // commit once for all DML in the script
8184
);
8285
console.log("Rows updated: " + result.rowsAffected); // 2
86+
console.log("ROWID of final row updated: " + result.lastRowid); // only gives one
8387

8488
} catch (err) {
8589
console.error(err);

0 commit comments

Comments
 (0)