I logged in as user AN and created a procedure in sql developer:
CREATE OR REPLACE PROCEDURE **viewSystemUsers**
AS
sysRefCursor SYS_REFCURSOR;
BEGIN
OPEN sysRefCursor
FOR
SELECT USERNAME, USER_ID, PASSWORD FROM dba_users;
dbms_sql.return_result(sysRefCursor);
END;
And executed it, this worked normally. After that i successfully connected as the same user using node-oracledb:
oracle.getConnection(
{
user : "AN",
password: "AN123",
connectString: "localhost:1521/orcl"
},
(error, **connection**) => {
if(error){
console.error(error.message);
return;
}
else
console.log('connect sucessfully!');
But when i set the EXECUTE query:
**connection**.execute(
`execute **viewSystemUsers**;`,
(err, result) => {
if(err){
console.error(err);
return;
}
console.log(result);
I received [Error: ORA-00900: invalid SQL statement] { errorNum: 900, offset: 0 }. Can anyone help me to fix it? Thank you very much.
dbms_sql.return_result? If it does not then you may need to use anOUTparameter on the procedure (which would be the typical way of achieving the same result). - MT0SYS_REFCURSORvariable as anOUTparameter, call the procedure and then loop through the variable to get the result set. - MT0