1
votes

I've connected my web server node.js to Oracle, and I've already select some data from de database.

There is no problem when I select data types like string or int, but I need to read some BLOBs too (called PARAMETERS in my database).

  • First problem: The size of the BLOBs stored in the data base is 37000 bytes, but the size max of the buffer is 2000 -->Solution : I've only selected the first 2000 bytes

  • Second problem: The result is an array, but I think that it's empty or I'm not able to read the data inside --> Solution?

Does anyone know how to read a BLOB with the node.js-Oracle module?

Thank you very much!

db.connect({ "hostname": "xxx", "user":"xx", "password": "xx", "database": "xx"},     function(err, connection) {
            if (err) {
                return console.log("CONNECTION ERROR: " + err);
            }
            else{
                console.log('Connected to Oracle ');
                connection.execute('SELECT utl_raw.cast_to_varchar2(dbms_lob.substr(PARAMETERS,2000,1)) FROM records WHERE records.id = 1', [], function (err, rows) {
                        if ( err ) {
                            console.log('error: ' + err);
                        }
                        console.log('Parameters= ' + rows);
                        socket.emit('response:record', {'record': rows});
                 });
                 connection.execute('SELECT records.name FROM records WHERE records.id = 1', [], function (err, rows) {
                        if ( err ) {
                            console.log('error: ' + err);
                        }
                        socket.emit('response:name', {'record': rows});
                        console.log('name= ' + rows);
                 });
               connection.close();
               }
});

The result is :

Connected to Oracle
Parameters = [object object]
name = [{NAME: ARD}]

1
which module do you use exactly (oracle or db-oracle)? - Andrei Karpushonak

1 Answers

0
votes

You shall update version of your oracle module to the latest one - 0.3.4 It has better support for BLOBs.

You can do it as following:

npm update oracle