node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

Truncate query not working

Open r04drunn3r opened this issue 10 years ago • 12 comments

Truncate query not working

Whenever I try to execute a truncate statement, it does not respond. This is causing inactive sessions in the table and slowing it down.

  1. What error(s) you are seeing? I do not see any errors.
  2. What exact command caused the problem (e.g. what command did you try to install with)? Who were you logged in as?
app.get('/api/RemoveAllitems', function (req, res) {
        oracledb.autoCommit = true;
        oracledb.getConnection(database, function (err, connection) {
            if (err) res.send(err);
            connection.execute("truncate table mytable", [], {}, function (err, result) {
                if (err) res.send(err);
                res.send(200);
                doRelease(connection);
            });
        });
    });
  1. What environment variables did you set? How exactly did you set them? I did nothave any problems compiling the library. I set all the environment variables mentioned in the docs.
  2. What is your version of Node.js? 4.6.0
  3. What is your version of the Oracle client (e.g. Instant Client)? How was it installed? Where it is installed? 12,1
  4. What is your OS and version? Windows server
  5. What compiler version did you use? Visual Studio2012

r04drunn3r avatar Oct 15 '16 12:10 r04drunn3r

are you aware that in case of error you are doing res.send twice right?

if (err) res.send(err);
res.send(200);

also i'm not sure what is res.send(200), did you mean res.status(200)?

sagiegurari avatar Oct 15 '16 13:10 sagiegurari

are you aware that in case of error you are doing res.send twice right?

if (err) res.send(err); res.send(200); also i'm not sure what is res.send(200), did you mean res.status(200)?

All that doesn't matter because the control never reaches the callback function.

r04drunn3r avatar Oct 15 '16 15:10 r04drunn3r

Ok. Didnt understand that from the problem description.

sagiegurari avatar Oct 15 '16 15:10 sagiegurari

@r04drunn3r I just ran the following test successfully, could you please try it?

var oracledb = require('oracledb');
var config = require('dbconfig');

oracledb.getConnection(config, function(err, connection) {
  if (err) {throw err;}

  connection.execute('create table t (c varchar(255))', function(err, result) {
    if (err) {throw err;}

    console.log('table created');

    connection.execute('insert into t (c) values (\'test\')', [], {autoCommit: true}, function(err, result) {
      if (err) {throw err;}

      console.log('row inserted');

      connection.execute('truncate table t', function(err, result) {
        if (err) {throw err;}

        console.log('truncate succeeded');

        connection.execute('drop table t', function(err, result) {
          if (err) {throw err;}

          console.log('table dropped');
        });
      });
    });
  });
});

dmcghan avatar Oct 15 '16 16:10 dmcghan

Did try that piece of code. The console just gets stuck at 'row inserted' output.

r04drunn3r avatar Oct 16 '16 13:10 r04drunn3r

does it work via sqlplus/other sql editor?

sagiegurari avatar Oct 16 '16 14:10 sagiegurari

i just checked. It does not. But then, that I believe is because of the lock created by this function.

r04drunn3r avatar Oct 16 '16 16:10 r04drunn3r

@r04drunn3r Lock created by what function?

dmcghan avatar Oct 16 '16 16:10 dmcghan

Lock created by the truncate query using nodejs.

r04drunn3r avatar Oct 17 '16 06:10 r04drunn3r

your nodejs was working while you were running it via sqlplus? can you kill all processes running against that oracle and try again? than if works, retry via nodejs.

sagiegurari avatar Oct 17 '16 06:10 sagiegurari

The issue seems to be specific to latest ODA X5-2 with Flash cache. Not an issue with the driver. I believe this issue can be closed.

r04drunn3r avatar Oct 26 '16 13:10 r04drunn3r

Thanks for giving the status update. Closing as requested.

cjbj avatar Oct 27 '16 00:10 cjbj