Skip to main content
Cadet | Tier 2
April 11, 2023
Question

I want to call the stored procedure using JavaScript in AA

  • April 11, 2023
  • 4 replies
  • 346 views

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

rbkadiyam
Premier Pathfinder | Tier 7
Premier Pathfinder | Tier 7
April 12, 2023

@Priyanka.H2 what error u r getting

Ramesh B Kadiyam
Cadet | Tier 2
April 12, 2023

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

Navigator | Tier 3
April 12, 2023

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.

Cadet | Tier 2
April 12, 2023

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