问题描述:

Error: ORA-32102: invalid OCI handle

var oracle = require('oracle');

oracle.connect({ "hostname": "hostname", "user": "user", "password": "password" },

function(err, connection) {

if(err){ console.log("Connect err:" + err); }

if(connection){ console.log("Connection:" + connection); }

console.log(connection);

console.log("........");

// selecting rows

connection.execute("SELECT * FROM AUTOLOAN_MASTER WHERE RELIGION = :1", ['R'],

function(err, results) {

if (err) {

console.log('Failed to query table in Oracle: '+ err);

req.results = null;

}

console.log(req);

console.log(req.results);

});

connection.close();

});

Oracle package has been installed in ubuntu.

Getting following error:

Error: ORA-32102: invalid OCI handle

网友答案:

Just had this same issue. Move the connection.close into your execute function. Because this is Node and things are running non blocking, it is closing your connection before the results are sent back.

var oracle = require('oracle');

oracle.connect({ "hostname": "hostname", "user": "user", "password": "password" },
  function(err, connection) {

    if(err){ console.log("Connect err:" + err); }
    if(connection){ console.log("Connection:" + connection); }

    console.log(connection);
    console.log("........");

    // selecting rows
    connection.execute("SELECT * FROM AUTOLOAN_MASTER WHERE RELIGION = :1", ['R'], 
      function(err, results) {
        if (err) {
          console.log('Failed to query table in Oracle: '+ err);
          req.results = null;
        }
        console.log(req);
        console.log(req.results);
        connection.close(); // Moved inside execute callback
   });
});
相关阅读:
Top