0
votes

I want to execute a stored procedure in Oracle, from my debian server with a nodejs file, in windows it works, but when i execute the same code in my debian server, it doesn't work, i cannot try with SQLPLUS because i don't have the permission on the server, that's the main reason because I'm trying with a nodejs.file

  • Node Version debian server: 10.17.0
  • Node Version Windows: 12.14.1
  • node-oracledb version = 4.2.0

Error:

[Error: ORA-00900: invalid SQL statement] errorNum: 900, offset: 0 }

  • ORACLE DB: 11g R1

Code:

    const oracledb = require('oracledb');

    oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;

    const mypw = 'bikeutal'  

    async function run() {

      let connection;

      try {
        connection = await oracledb.getConnection(  {
          user          : "user",
          password      : mypw,
          connectString : "host/sys"
        });

        const result = await connection.execute(
          `exec actualizar_rating();`//bad
          //`BEGIN BIKE_UTAL.ACTUALIZAR_RATING(); END ;`//bad

          //`exec ACTUALIZAR_RATING()` //bad
          //"CALL ACTUALIZAR_RATING()" //bad
          //`EXECUTE ACTUALIZAR_RATING()`// bad
          //`SELECT * FROM dev_viajes` //work
          //

         // console.log(result);
         );
      } catch (err) {
        console.error(err);
      } finally {
        if (connection) {
          try {
            await connection.close();
          } catch (err) {
            console.error(err);
          } 
        }
      }
    }

    run();
1

1 Answers

0
votes
  • EXEC (and its full name EXECUTE) is a SQL*Plus command. It is a not SQL statement so the database doesn't understand it. Any error in Node.js using this command is expected.

  • What error are you getting with BEGIN BIKE_UTAL.ACTUALIZAR_RATING(); END ;?

  • Are you sure you're connecting to the same database on Debian as you are connecting to on Windows?

  • If you can use node-oracledb in Node.js you should easily be able to use SQL*Plus on the same computer.

  • Node-oracledb documentation on calling PL/SQL stored procedures is in PL/SQL Stored Procedure.