-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
- What versions are you using?
Oracle database version: "Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0"
NLS_CHARACTERSET: AL32UTF8
process.platform=win32
process.version=v16.10.0
process.arch=x64
Note that this issue affects nodejs running on linux as well.
oracledb version: 6.0.3 (thick mode)
oracle client version: 21.10.0.0.0
-
Is it an error or a hang or a crash? An exception
-
What error(s) or behavior you are seeing?
This error happens in oracledb version 6 using thick mode.
Error: ORA-21525: attribute number or (collection element at index) %s violated its constraints
at async executeSql (C:\...\oracledb6.js:22:18) {
errorNum: 21525,
offset: 0,
code: 'ORA-21525'
}
- Include a runnable Node.js script that shows the problem.
I created the following script and ran it on oracledb 6.0.3, 6.0.0, 5.5.0, 4.2.0 (see below for output).
Please note that I am required to use thick mode as the current oracledb version does not support NNE.
const oracledb = require('oracledb');
oracledb.initOracleClient({});
console.log('oracledb version: ' + oracledb.versionString);
console.log('oracledb thin mode: ' + oracledb.thin);
if (!oracledb.thin) {
console.log('oracle client version: ' + oracledb.oracleClientVersionString);
}
executeSql().then(() => console.log('Done'));
async function executeSql() {
let pool = null, connection = null;
try {
pool = await oracledb.createPool({
user: '',
password: '',
connectString: ''
});
connection = await pool.getConnection();
await connection.execute('create or replace type MY_TYPE as object (TESTNUMBER number (12, 0))');
let rs = await connection.execute(`declare myType MY_TYPE := :t; begin myType.TESTNUMBER := 2; :t := myType; end;`, {
t: {
dir: oracledb.BIND_INOUT,
type: 'MY_TYPE',
val: {'TESTNUMBER': 1}
}
}, {outFormat: oracledb.OUT_FORMAT_OBJECT});
console.log(JSON.stringify(rs.outBinds));
} catch (e) {
console.log(e);
} finally {
if (connection) {
await connection.execute('drop type MY_TYPE');
await connection.close();
}
if (pool) {
await pool.close(10);
}
}
}oracledb version: 6.0.3
oracledb thin mode: false
oracle client version: 21.10.0.0.0
Error: ORA-21525: attribute number or (collection element at index) %s violated its constraints
at async executeSql (C:\...\oracledb6.js:22:18) {
errorNum: 21525,
offset: 0,
code: 'ORA-21525'
}
Done
oracledb version: 6.0.3
oracledb thin mode: true
{"t":{"TESTNUMBER":2}}
Done
oracledb version: 6.0.0
oracledb thin mode: false
oracle client version: 21.10.0.0.0
Error: ORA-21525: attribute number or (collection element at index) %s violated its constraints
at async executeSql (C:\...\oracledb6.js:22:18) {
errorNum: 21525,
offset: 0,
code: 'ORA-21525'
}
Done
oracledb version: 6.0.0
oracledb thin mode: true
{"t":{"TESTNUMBER":2}}
Done
oracledb version: 5.5.0
oracledb thin mode: undefined
oracle client version: 21.10.0.0.0
{"t":{"TESTNUMBER":2}}
Done
oracledb version: 4.2.0
oracledb thin mode: undefined
oracle client version: 21.10.0.0.0
{"t":{"TESTNUMBER":2}}
Done
Some of my own analysis:
The issue appears to be related to the number constraint in my type. If I change the constraint to NUMBER(22,0) then the script works successfully. Other smaller values work too such as (20,0) and (14,0), but for some reason (12,0), (11,0), etc. don't work anymore since oracledb version 6.
Thank you in advance for any help in resolving this issue.