Note that there are some explanatory texts on larger screens.

plurals
  1. PORead a BLOB in Oracle from Node.js
    text
    copied!<p>I've connected my web server node.js to Oracle, and I've already select some data from de database.</p> <p>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).</p> <ul> <li><p>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</p></li> <li><p>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?</p></li> </ul> <p>Does anyone know how to read a BLOB with the node.js-Oracle module?</p> <p>Thank you very much!</p> <pre><code>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(); } }); </code></pre> <p>The result is :</p> <p>Connected to Oracle<br> Parameters = [object object]<br> name = [{NAME: ARD}]</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload