1

off the bat I have looked and tried the following

     https://stackoverflow.com/questions/50679120/oracle-db-select-query-returning-the-data-in-form-of-array-instead-of-json-array

^ this is my exact same problem and I have tried the solution and it doesn't work for me.

I also copied the exact same code for as the doucmentation

     https://github.com/oracle/node-   oracledb/blob/main/examples/example.js#L32:~:text=sql%20%3D%20%60SELECT%20*%20FROM%20no_example%60%3B,rows%2C%20%7B%20depth%3A%20null%20%7D)%3B]

and it still doesn't work.

Below is my code which I am using with node v19.3.0, and oracledb 5.5 (please note it does connect to the DB correctly)

      if (err) {
         console.error(err.message);
         return;
      }
      else{
       options = {
        outFormat: oracledb.OUT_FORMAT_OBJECT,   // query result format
         //extendedMetaData: true               // get extra metadata
       };
       let query = "SELECT * FROM ACCOUNTS";
       binds = {};
       const result = await connection.execute(query, binds, options); 
       console.log(result);
       doRelease(connection);
      }

from this the output is

     {
       metaData: [ { name: 'USERNAME' }, { name: 'TOKENS' }, { name: 'PASSWORD' } ],
       rows: []
     }
    Connection released

However if I run this exact same query in sql developer (obviously connected to the same DB and with same credentials) I get all accounts... Does anyone know what may be causing this? I am trying to get the values of the fields!

The expected output for this should have been the data inside the table which is 'test' 20, '[email protected]'

5
  • "Doesn't work" tells exactly nothing about actual issue. Does it return the data you didn't expect? Does it throw an error? What error? Commented Dec 31, 2022 at 7:13
  • 1
    Doesn't work as instead of returning the values from the table it returns the column names... The expected out put should be 'test1', 20, '[email protected]' Since theres only 1 row in the table Commented Dec 31, 2022 at 14:49
  • Did you check the reference documentation? By default, queries are handled as ‘direct fetches’, meaning all results are returned in the callback result.rows property Commented Dec 31, 2022 at 16:01
  • 1
    Yes, as you can see the rows array in the output is always empty. Commented Dec 31, 2022 at 16:25
  • My guess is that you've inserted rows into your table but haven't COMMITted the transaction in SQL Developer. Until you do commit. only the SQL Developer session can see the rows you've inserted. Commented Dec 31, 2022 at 20:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.