In Node.js, use the OracleDB library to execute Oracle database stored procedures: Install the OracleDB library. Create a database connection. Define the stored procedure name and parameters. Execute the stored procedure. Close the database connection.
In Node.js, you can use the OracleDB library to execute Oracle database stored procedures.
<code>npm install oracledb</code>
const oracledb = require('oracledb'); async function createConnection() { return oracledb.getConnection(connectionParams); }
const procedureName = 'MY_PROCEDURE'; const parameters = { input: oracledb.NUMBER, output: oracledb.OUT };
async function executeProcedure(connection) { const result = await connection.execute( procedureName, parameters, { autoCommit: true } ); return result.outBinds; }
async function closeConnection(connection) { await connection.close(); }
const connectionParams = { user: 'username', password: 'password', connectString: 'host:port/databasename' }; createConnection() .then(connection => executeProcedure(connection)) .then(result => console.log(result)) .catch(err => console.error(err)) .finally(() => closeConnection(connection));
The above is the detailed content of How to run oracle database stored procedure in nodejs. For more information, please follow other related articles on the PHP Chinese website!