@@ -33,13 +33,24 @@ const dbconfig = require('./dbconfig.js');
33
33
34
34
describe ( '240. errorOffset.js' , async ( ) => {
35
35
36
- it ( '240.1 checks the offset value of the error' , async ( ) => {
37
- let conn ;
36
+ let conn ;
37
+ before ( async ( ) => {
38
38
try {
39
39
conn = await oracledb . getConnection ( dbconfig ) ;
40
40
} catch ( error ) {
41
41
should . not . exist ( error ) ;
42
42
}
43
+ } ) ;
44
+
45
+ after ( async ( ) => {
46
+ try {
47
+ await conn . close ( ) ;
48
+ } catch ( error ) {
49
+ should . not . exist ( error ) ;
50
+ }
51
+ } ) ;
52
+
53
+ it ( '240.1 checks the offset value of the error' , async ( ) => {
43
54
44
55
try {
45
56
await conn . execute ( "begin t_Missing := 5; end;" ) ;
@@ -49,10 +60,54 @@ describe('240. errorOffset.js', async () => {
49
60
should . strictEqual ( error . errorNum , 6550 ) ;
50
61
}
51
62
63
+ } ) ; // 240.1
64
+
65
+ it ( '240.2 database error' , async ( ) => {
66
+
67
+ const plsql = `
68
+ begin
69
+ execute immediate ('drop table nodb_table_nonexistent');
70
+ end;
71
+ ` ;
52
72
try {
53
- await conn . close ( ) ;
73
+ await conn . execute ( plsql ) ;
54
74
} catch ( error ) {
55
- should . not . exist ( error ) ;
75
+ should . exist ( error ) ;
76
+ should . strictEqual ( error . offset , 0 ) ;
77
+ should . strictEqual ( error . errorNum , 942 ) ;
56
78
}
57
- } ) ;
79
+
80
+ } ) ; // 240.2
81
+
82
+ it ( '240.3 the offset of system error is 0' , async ( ) => {
83
+ const plsql = `
84
+ BEGIN
85
+ DECLARE v_invalid PLS_INTEGER;
86
+ BEGIN
87
+ v_invalid := 100/0;
88
+ END;
89
+ END;
90
+ ` ;
91
+ try {
92
+ await conn . execute ( plsql ) ;
93
+ } catch ( error ) {
94
+ should . exist ( error ) ;
95
+ should . strictEqual ( error . offset , 0 ) ;
96
+ should . strictEqual ( error . errorNum , 1476 ) ;
97
+ }
98
+ } ) ; // 240.3
99
+
100
+ it ( '240.4 PL/SQL syntax error' , async ( ) => {
101
+ const plsql = `DECLARE v_missing_semicolon PLS_INTEGER
102
+ BEGIN
103
+ v_missing_semicolon := 46;
104
+ END;` ;
105
+ try {
106
+ await conn . execute ( plsql ) ;
107
+ } catch ( error ) {
108
+ should . exist ( error ) ;
109
+ should . strictEqual ( error . offset , 46 ) ;
110
+ should . strictEqual ( error . errorNum , 6550 ) ;
111
+ }
112
+ } ) ; // 240.4
58
113
} ) ;
0 commit comments