Node-oracledb: Problem with basic select

Created on 18 Nov 2020  路  5Comments  路  Source: oracle/node-oracledb

node version: v15.2.0
oracledb version: 5.0.0
oracle: 18c

when I executed my select from node js this response is strange,
for example when I used const result = await connection.execute('SELECT * FROM PRUEBA');
I had this answer:
imagen
imagen

and when I used const result = await connection.execute('SELECT * FROM USUARIO');
I had this answer:
imagen
imagen

my code is:

require('./config/config');
const oracledb = require('oracledb');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/usuario', async(req, res) => {
    console.log('GET USUARIO');
    try {
        connection = await oracledb.getConnection({
            user: "matias",
            password: "123",
            connectString: "localhost:1521/xe"
        });
        const result = await connection.execute('SELECT * FROM USUARIO');
        res.json(result);
    } catch (err) {
        console.error(err);
    } finally {
        if (connection) {
            try {
                await connection.close();
            } catch (err) {
                console.error(err);
            }
        }
    }
});
question

All 5 comments

What is strange? You showed two different queries giving two different results? What did you expect in node-oracledb?

[Tips for the next issue you post: don't post screen shots - not everyone can read them and no-one can cut-and-paste from them. Use triple backticks before & after code to format it properly.]

What is strange? You showed two different queries giving two different results? What did you expect in node-oracledb?

[Tips for the next issue you post: don't post screen shots - not everyone can read them and no-one can cut-and-paste from them. Use triple backticks before & after code to format it properly.]

sorry I'm new.
but my table "PRUEBA" has data and is not displayed.

Are you connected to the correct DB as the correct person - this is a very common cause of similar problems

The other common cause is the lack of a COMMIT in the tool that inserted the data.

Are you connected to the correct DB as the correct person - this is a very common cause of similar problems

The other common cause is the lack of a COMMIT in the tool that inserted the data.

Yes with commit its ok! thx!

now i have another problem with an INOUT cursor you can help me?

i have this code:

            let parametros = {
                id: 2,
                CURSOR_: { dir: oracledb.BIND_INOUT, type: oracledb.CURSOR }
            }

            const result = await connection.execute(
                'BEGIN LEER_DEPARTAMENTO(:id, :CURSOR_); END;',
                parametros
            );
            const resultSet = result.outBinds.cursor;

            res.json(resultSet);

this returns nothing.

I'm glad it's working.

Regarding the second question, review the doc and examples and open a new issue (giving us a runnable example) if you still have problems.

I'll close this issue now the original question has been answered.

Was this page helpful?
0 / 5 - 0 ratings