Question

I want to call the stored procedure using JavaScript in AA

  • 11 April 2023
  • 4 replies
  • 47 views

Badge +2

Hi,

below is the javascript which I am trying to call but getting error.

Kindly help me

const oracle = require('oracle');

const connection = oracle.createConnection({
  host: '',
  port:'',
  user: '',
  password: '',
  servicename: ''
});

connection.connect();

const myProcedure = "CALL SPNAME(parameter1, parameter2, @return_code); SELECT @return_code;";

connection.query(myProcedure, ['?', '?'], (err, rows) => {
  if (err) {
    throw err;
  }

  const outputParam = rows[1][0]['@return_code'];
  console.log(outputParam);
});

connection.end();


4 replies

Userlevel 5
Badge +10

@Priyanka.H2 what error u r getting

Badge +2

Named export 'createConnection' not found. The requested module 'oracle' is a CommonJS module, which may not support all module.exports as named exports.

Userlevel 3
Badge +6

You are using this wrong. This script won’t run using run JavaScript action.
require() is not part of the standard JavaScript API. But in Node.js, it's a built-in function with a special purpose: to load modules.

Badge +2

can you please help me with the basic javascript code. I want to call the stored procedure with input parameter in AA.

Reply