@@ -154,30 +154,34 @@ row_t* Connection::CreateRowFromCurrentResultSetRow(oracle::occi::ResultSet* rs,
154
154
int colIndex = 1 ;
155
155
for (std::vector<column_t *>::iterator iterator = columns.begin (), end = columns.end (); iterator != end; ++iterator, colIndex++) {
156
156
column_t * col = *iterator;
157
- switch (col->type ) {
158
- case VALUE_TYPE_STRING:
159
- row->values .push_back (new std::string (rs->getString (colIndex)));
160
- break ;
161
- case VALUE_TYPE_NUMBER:
162
- row->values .push_back (new oracle::occi::Number (rs->getNumber (colIndex)));
163
- break ;
164
- case VALUE_TYPE_DATE:
165
- row->values .push_back (new oracle::occi::Date (rs->getDate (colIndex)));
166
- break ;
167
- case VALUE_TYPE_TIMESTAMP:
168
- row->values .push_back (new oracle::occi::Timestamp (rs->getTimestamp (colIndex)));
169
- break ;
170
- case VALUE_TYPE_CLOB:
171
- row->values .push_back (new oracle::occi::Clob (rs->getClob (colIndex)));
172
- break ;
173
- case VALUE_TYPE_BLOB:
174
- row->values .push_back (new oracle::occi::Blob (rs->getBlob (colIndex)));
175
- break ;
176
- default :
177
- std::ostringstream message;
178
- message << " CreateRowFromCurrentResultSetRow: Unhandled type: " << col->type ;
179
- throw NodeOracleException (message.str ());
180
- break ;
157
+ if (rs->isNull (colIndex)) {
158
+ row->values .push_back (NULL );
159
+ } else {
160
+ switch (col->type ) {
161
+ case VALUE_TYPE_STRING:
162
+ row->values .push_back (new std::string (rs->getString (colIndex)));
163
+ break ;
164
+ case VALUE_TYPE_NUMBER:
165
+ row->values .push_back (new oracle::occi::Number (rs->getNumber (colIndex)));
166
+ break ;
167
+ case VALUE_TYPE_DATE:
168
+ row->values .push_back (new oracle::occi::Date (rs->getDate (colIndex)));
169
+ break ;
170
+ case VALUE_TYPE_TIMESTAMP:
171
+ row->values .push_back (new oracle::occi::Timestamp (rs->getTimestamp (colIndex)));
172
+ break ;
173
+ case VALUE_TYPE_CLOB:
174
+ row->values .push_back (new oracle::occi::Clob (rs->getClob (colIndex)));
175
+ break ;
176
+ case VALUE_TYPE_BLOB:
177
+ row->values .push_back (new oracle::occi::Blob (rs->getBlob (colIndex)));
178
+ break ;
179
+ default :
180
+ std::ostringstream message;
181
+ message << " CreateRowFromCurrentResultSetRow: Unhandled type: " << col->type ;
182
+ throw NodeOracleException (message.str ());
183
+ break ;
184
+ }
181
185
}
182
186
}
183
187
return row;
@@ -267,50 +271,54 @@ Local<Object> Connection::CreateV8ObjectFromRow(ExecuteBaton* baton, row_t* curr
267
271
for (std::vector<column_t *>::iterator iterator = baton->columns .begin (), end = baton->columns .end (); iterator != end; ++iterator, colIndex++) {
268
272
column_t * col = *iterator;
269
273
void * val = currentRow->values [colIndex];
270
- switch (col->type ) {
271
- case VALUE_TYPE_STRING:
272
- {
273
- std::string* v = (std::string*)val;
274
- obj->Set (String::New (col->name .c_str ()), String::New (v->c_str ()));
275
- delete v;
276
- }
277
- break ;
278
- case VALUE_TYPE_NUMBER:
279
- {
280
- oracle::occi::Number* v = (oracle::occi::Number*)val;
281
- obj->Set (String::New (col->name .c_str ()), Number::New ((double )(*v)));
282
- delete v;
283
- }
284
- break ;
285
- case VALUE_TYPE_DATE:
286
- {
287
- oracle::occi::Date* v = (oracle::occi::Date*)val;
288
- obj->Set (String::New (col->name .c_str ()), OracleDateToV8Date (v));
289
- }
290
- break ;
291
- case VALUE_TYPE_TIMESTAMP:
292
- {
293
- oracle::occi::Timestamp* v = (oracle::occi::Timestamp*)val;
294
- obj->Set (String::New (col->name .c_str ()), OracleTimestampToV8Date (v));
295
- }
296
- break ;
297
- case VALUE_TYPE_CLOB:
298
- {
299
- oracle::occi::Clob* v = (oracle::occi::Clob*)val;
300
- obj->Set (String::New (col->name .c_str ()), Null ()); // TODO: handle clobs
301
- }
302
- break ;
303
- case VALUE_TYPE_BLOB:
304
- {
305
- oracle::occi::Blob* v = (oracle::occi::Blob*)val;
306
- obj->Set (String::New (col->name .c_str ()), Null ()); // TODO: handle blobs
307
- }
308
- break ;
309
- default :
310
- std::ostringstream message;
311
- message << " CreateV8ObjectFromRow: Unhandled type: " << col->type ;
312
- throw NodeOracleException (message.str ());
313
- break ;
274
+ if (val == NULL ) {
275
+ obj->Set (String::New (col->name .c_str ()), Null ());
276
+ } else {
277
+ switch (col->type ) {
278
+ case VALUE_TYPE_STRING:
279
+ {
280
+ std::string* v = (std::string*)val;
281
+ obj->Set (String::New (col->name .c_str ()), String::New (v->c_str ()));
282
+ delete v;
283
+ }
284
+ break ;
285
+ case VALUE_TYPE_NUMBER:
286
+ {
287
+ oracle::occi::Number* v = (oracle::occi::Number*)val;
288
+ obj->Set (String::New (col->name .c_str ()), Number::New ((double )(*v)));
289
+ delete v;
290
+ }
291
+ break ;
292
+ case VALUE_TYPE_DATE:
293
+ {
294
+ oracle::occi::Date* v = (oracle::occi::Date*)val;
295
+ obj->Set (String::New (col->name .c_str ()), OracleDateToV8Date (v));
296
+ }
297
+ break ;
298
+ case VALUE_TYPE_TIMESTAMP:
299
+ {
300
+ oracle::occi::Timestamp* v = (oracle::occi::Timestamp*)val;
301
+ obj->Set (String::New (col->name .c_str ()), OracleTimestampToV8Date (v));
302
+ }
303
+ break ;
304
+ case VALUE_TYPE_CLOB:
305
+ {
306
+ oracle::occi::Clob* v = (oracle::occi::Clob*)val;
307
+ obj->Set (String::New (col->name .c_str ()), Null ()); // TODO: handle clobs
308
+ }
309
+ break ;
310
+ case VALUE_TYPE_BLOB:
311
+ {
312
+ oracle::occi::Blob* v = (oracle::occi::Blob*)val;
313
+ obj->Set (String::New (col->name .c_str ()), Null ()); // TODO: handle blobs
314
+ }
315
+ break ;
316
+ default :
317
+ std::ostringstream message;
318
+ message << " CreateV8ObjectFromRow: Unhandled type: " << col->type ;
319
+ throw NodeOracleException (message.str ());
320
+ break ;
321
+ }
314
322
}
315
323
}
316
324
return obj;
0 commit comments