Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORA-21525 when using oracledb version 6 thick mode #1594

Closed
shinyredcobra opened this issue Aug 21, 2023 · 2 comments
Closed

ORA-21525 when using oracledb version 6 thick mode #1594

shinyredcobra opened this issue Aug 21, 2023 · 2 comments

Comments

@shinyredcobra
Copy link

shinyredcobra commented Aug 21, 2023

  1. 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

  1. Is it an error or a hang or a crash? An exception

  2. 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'
}
  1. 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.

@cjbj
Copy link
Member

cjbj commented Aug 23, 2023

I can reproduce. We'll look at it. Thanks for raising the issue.

sharadraju added a commit that referenced this issue Sep 15, 2023
@sharadraju
Copy link
Member

This is fixed in the 6.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants