20
20
*
21
21
* DESCRIPTION
22
22
* Show the auto commit behavior.
23
- *
23
+ *
24
24
* By default, node-oracledb does not commit on execute.
25
25
* The driver also has commit() and rollback() methods to explicitly control transactions.
26
- *
26
+ *
27
27
* Note: when a connection is closed, any open transaction will be committed.
28
28
*
29
29
*****************************************************************************/
@@ -52,7 +52,7 @@ oracledb.getConnection(
52
52
return ;
53
53
}
54
54
console . log ( "Table created" ) ;
55
-
55
+
56
56
connection1 . execute (
57
57
"INSERT INTO test VALUES (:id, :nm)" ,
58
58
[ 1 , 'Chris' ] , // Bind values
@@ -61,7 +61,7 @@ oracledb.getConnection(
61
61
{
62
62
if ( err ) { console . error ( err . message ) ; return ; }
63
63
console . log ( "Rows inserted: " + result . rowsAffected ) ; // 1
64
-
64
+
65
65
connection1 . execute (
66
66
"INSERT INTO test VALUES (:id, :nm)" ,
67
67
[ 2 , 'Alison' ] , // Bind values
@@ -70,7 +70,7 @@ oracledb.getConnection(
70
70
{
71
71
if ( err ) { console . error ( err . message ) ; return ; }
72
72
console . log ( "Rows inserted: " + result . rowsAffected ) ; // 1
73
-
73
+
74
74
// Create a second connection
75
75
oracledb . getConnection (
76
76
{
@@ -95,14 +95,14 @@ oracledb.getConnection(
95
95
// This will only show 'Chris' because inserting 'Alison' is not commited by default.
96
96
// Uncomment the isAutoCommit option above and you will see both rows
97
97
console . log ( result . rows ) ;
98
-
98
+
99
99
connection1 . execute (
100
100
"DROP TABLE test" ,
101
101
function ( err )
102
102
{
103
103
if ( err ) { console . error ( err . message ) ; return ; }
104
104
console . log ( "Table dropped" ) ;
105
-
105
+
106
106
connection2 . release (
107
107
function ( err )
108
108
{
@@ -112,12 +112,12 @@ oracledb.getConnection(
112
112
{
113
113
if ( err ) { console . error ( err . message ) ; return ; }
114
114
} ) ;
115
-
115
+
116
116
} ) ;
117
117
} ) ;
118
118
} ) ;
119
119
} ) ;
120
120
} ) ;
121
- } ) ;
121
+ } ) ;
122
122
} ) ;
123
123
} ) ;
0 commit comments