Permalink
Browse files

Added CLOB support

  • Loading branch information...
1 parent 4be6e6a commit b055cb6549dd739e949b9afaa54d660378c87eab Danny Brain committed Mar 5, 2013
Showing with 15 additions and 5 deletions.
  1. +13 −3 src/connection.cpp
  2. +2 −2 test/integration.js
View
16 src/connection.cpp
@@ -121,7 +121,7 @@ Handle<Value> Connection::Rollback(const Arguments& args) {
uv_work_t* req = new uv_work_t();
req->data = baton;
uv_queue_work(uv_default_loop(), req, EIO_Rollback, EIO_AfterRollback);
-
+
connection->Ref();
return Undefined();
@@ -405,8 +405,18 @@ Local<Object> Connection::CreateV8ObjectFromRow(ExecuteBaton* baton, row_t* curr
break;
case VALUE_TYPE_CLOB:
{
- //oracle::occi::Clob* v = (oracle::occi::Clob*)val;
- obj->Set(String::New(col->name.c_str()), Null()); // TODO: handle clobs
+ oracle::occi::Clob* v = (oracle::occi::Clob*)val;
+ v->open(oracle::occi::OCCI_LOB_READONLY);
+ v->setCharSetForm(oracle::occi::OCCI_SQLCS_NCHAR);
+
+ int clobLength = v->length();
+ oracle::occi::Stream *instream = v->getStream(1,0);
+ char *buffer = new char[clobLength];
+ memset(buffer, NULL, clobLength);
+ instream->readBuffer(buffer, clobLength);
+ v->closeStream(instream);
+
+ obj->Set(String::New(col->name.c_str()), String::New(buffer));
}
break;
case VALUE_TYPE_BLOB:
View
4 test/integration.js
@@ -128,8 +128,8 @@ exports['IntegrationTest'] = nodeunit.testCase({
test.equal(results[0]['TDATE'].getTime(), date1.getTime());
var date2Timestamp = new Date(2011, 11, 1, 0, 0, 0); // same as date2 but without time
test.equal(results[0]['TTIMESTAMP'].getTime(), date2Timestamp.getTime());
- // todo: test.equal(results[0]['TCLOB'], "tclob value");
- // todo: test.equal(results[0]['TNCLOB'], "tnclob value");
+ test.equal(results[0]['TCLOB'], "tclob value");
+ test.equal(results[0]['TNCLOB'], "tnclob value");
// todo: test.equal(results[0]['TBLOB'], null);
test.done();
});

0 comments on commit b055cb6

Please sign in to comment.