node-oracledb calling procedure failed

74 Views Asked by At
import oracledb from 'oracledb';

try {
    oracledb.initOracleClient(libDirObj);   //success
    connection = await oracledb.getConnection({
        user:xxxx
        password:xxxx
        connectString:xxxx
    });//success

    let codeC ='3';

    await connection.execute(//failed
          `BEGIN packageName.procedureName(:codeA,:codeB,:codeC,:codeD,:codeE);END;`
           ,{
              codeA : { dir : oracledb.BIND_IN, val: 1111},
              codeB : { dir : oracledb.BIND_IN, val: ''},
              codeC : { dir : oracledb.BIND_IN, val: codeC},
              codeD : { dir : oracledb.BIND_OUT, type : oracledb.STRING},
              codeE : { dir : oracledb.BIND_INOUT, val: [20,30] , type: oracledb.NUMBER,maxArraySize: 200
            }
            ,{
            function (err, ret) {
               if (err) {
                   console.log('[ERROR] oracle:',e);   //show nothing  
               }else{
                   console.log('ret:',ret);   //show nothing
               }  
            }
} catch (e) {
   console.log('[ERROR] oracle:',e);   //show nothing
}

procedure

CREATE OR REPLACE packageName IS
TYPE char_array  IS TABLE OF VARCHAR2(10) INDEX BY BINARY_INTEGER;
TYPE num_array  IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
PROCEDURE procedureName(
   codeA IN NUMBER,
   codeB IN VARCHAR2,
   codeC IN VARCHAR2,
   codeD OUT VARCHAR2,
   codeE IN OUT num_array,
)

nodejs version : 18.16.1 oracledb version : 5.5.0 docker image push at aws ecs /aws linux 64bit

node-oracledb excute procedure get this error

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR Command was killed with SIGSEGV (Segmentation fault): node ./server/index.mjs
at makeError (node_modules/nuxi/dist/shared/nuxi.6b390535.mjs:619:11)
at handlePromise (node_modules/nuxi/dist/shared/nuxi.6b390535.mjs:1026:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.invoke (node_modules/nuxi/dist/chunks/preview.mjs:63:5)
at async _main (node_modules/nuxi/dist/cli.mjs:50:20)

and didnt show another info also
only when calling procedure get failed if calling another SELECT its succes
how could i fix this porblem pls help

1

There are 1 best solutions below

2
Christopher Jones On

You mixed the await usage with a callback function (err, ret). You should only use one of these. Use the await style. Check the node-oracledb doc or examples for how to call a PL/SQL procedure:

const result = await connection.execute(
    `BEGIN
        myproc(:id, :name, :salary);
    END;`,
    {  // bind variables
        id:   159,
        name: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 40 },
        salary: { dir: oracledb.BIND_OUT, type: oracledb.NUMBER }
    }
);

console.log(result.outBinds);