how to solve " ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'GET_TICKER_INFO' ORA-06550: line 1, column 7: PL/SQL: Statement ignored "?
Hi, I am new in node and Oracle. Not able to run the procedure using node js. need help to solve this Oracle procedure reference
PROCEDURE get_data_info (
p_ticker VARCHAR2,
p_acronym VARCHAR2,
p_sort VARCHAR2,
p_call_source VARCHAR2,
p_data OUT REF_CRS);
Node js code
sql = 'begin get_data_info(:p_ticker,:p_acronym,:p_sort,:p_call_source,:p_data); end;';
// run procedure to get all data
const ticker_data ={
p_ticker: '',
p_acronym: '',
p_sort: '',
p_call_source: '',
p_data: ''
};
data = { p_ticker: 'AAPL', p_data: ':output'};
binds = Object.assign({}, ticker_data, data);
options = {
outFormat: oracledb.OUT_FORMAT_OBJECT,
};
result = await connection.execute(sql, binds, options);
Guessing that REF_CRS
is a REF CURSOR, your problem is the definition of p_data
in the bind parameter object. You need to give it a type and direction like:
p_data: {dir: oracledb.BIND_OUT, type: oracledb.CURSOR}
Check the node-oracledb documentation chapter REF CURSOR Bind Parameters.
Working code would be like:
/*
create or replace PROCEDURE get_data_info (
p_ticker VARCHAR2,
p_acronym VARCHAR2,
p_sort VARCHAR2,
p_call_source VARCHAR2,
p_data OUT SYS_REFCURSOR) as
begin
open p_data for select * from dual;
end;
/
show errors
*/
const oracledb = require('oracledb');
const dbConfig = { user: 'cj', password: 'cj', connectString: 'localhost/orclpdb1' };
if (process.platform === 'darwin') {
oracledb.initOracleClient({libDir: '/Users/cjones/instantclient_19_3'});
}
let sql, binds, options, result;
sql = `SELECT TO_CHAR(CURRENT_DATE, 'DD-Mon-YYYY HH24:MI') AS D FROM DUAL`;
options = {
// outFormat: oracledb.OUT_FORMAT_OBJECT // uncomment if you want object output instead of array
};
async function run() {
let connection;
try {
connection = await oracledb.getConnection(dbConfig);
sql = 'begin get_data_info(:p_ticker,:p_acronym,:p_sort,:p_call_source,:p_data); end;';
const ticker_data = {
p_ticker: '',
p_acronym: '',
p_sort: '',
p_call_source: '',
p_data: ''
};
const data = { p_ticker: 'AAPL', p_data: {dir: oracledb.BIND_OUT, type: oracledb.CURSOR}};
const binds = Object.assign({}, ticker_data, data);
result = await connection.execute(sql, binds, options);
const resultSet = result.outBinds.p_data;
let row;
while ((row = await resultSet.getRow())) {
console.log(row);
}
await resultSet.close(); // always close the ResultSet
} catch (err) {
console.error(err);
} finally {
if (connection) {
try {
await connection.close();
} catch (err) {
console.error(err);
}
}
}
}
run();