@@ -114,12 +114,31 @@ void Connection::CreateColumnsFromResultSet(oracle::occi::ResultSet* rs, std::ve
114
114
int type = metadata.getInt (oracle::occi::MetaData::ATTR_DATA_TYPE);
115
115
switch (type) {
116
116
case oracle::occi::OCCI_TYPECODE_NUMBER:
117
+ case oracle::occi::OCCI_TYPECODE_FLOAT:
118
+ case oracle::occi::OCCI_TYPECODE_DOUBLE:
119
+ case oracle::occi::OCCI_TYPECODE_REAL:
120
+ case oracle::occi::OCCI_TYPECODE_DECIMAL:
121
+ case oracle::occi::OCCI_TYPECODE_INTEGER:
122
+ case oracle::occi::OCCI_TYPECODE_SMALLINT:
117
123
col->type = VALUE_TYPE_NUMBER;
118
124
break ;
119
125
case oracle::occi::OCCI_TYPECODE_VARCHAR2:
120
126
case oracle::occi::OCCI_TYPECODE_VARCHAR:
127
+ case oracle::occi::OCCI_TYPECODE_CHAR:
121
128
col->type = VALUE_TYPE_STRING;
122
129
break ;
130
+ case oracle::occi::OCCI_TYPECODE_CLOB:
131
+ col->type = VALUE_TYPE_CLOB;
132
+ break ;
133
+ case oracle::occi::OCCI_TYPECODE_DATE:
134
+ col->type = VALUE_TYPE_DATE;
135
+ break ;
136
+ case OCI_TYPECODE_TIMESTAMP:
137
+ col->type = VALUE_TYPE_TIMESTAMP;
138
+ break ;
139
+ case oracle::occi::OCCI_TYPECODE_BLOB:
140
+ col->type = VALUE_TYPE_BLOB;
141
+ break ;
123
142
default :
124
143
std::ostringstream message;
125
144
message << " CreateColumnsFromResultSet: Unhandled oracle data type: " << type;
@@ -142,9 +161,21 @@ row_t* Connection::CreateRowFromCurrentResultSetRow(oracle::occi::ResultSet* rs,
142
161
case VALUE_TYPE_NUMBER:
143
162
row->values .push_back (new oracle::occi::Number (rs->getNumber (colIndex)));
144
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 ;
145
176
default :
146
177
std::ostringstream message;
147
- message << " Unhandled type: " << col->type ;
178
+ message << " CreateRowFromCurrentResultSetRow: Unhandled type: " << col->type ;
148
179
throw NodeOracleException (message.str ());
149
180
break ;
150
181
}
@@ -196,6 +227,40 @@ void Connection::EIO_Execute(eio_req* req) {
196
227
}
197
228
}
198
229
230
+ void CallDateMethod (v8::Local<v8::Date> date, const char * methodName, int val) {
231
+ Handle<Value> args[1 ];
232
+ args[0 ] = Number::New (val);
233
+ Local<Function>::Cast (date->Get (String::New (methodName)))->Call (date, 1 , args);
234
+ }
235
+
236
+ Local<Date> OracleDateToV8Date (oracle::occi::Date* d) {
237
+ int year;
238
+ unsigned int month, day, hour, min, sec;
239
+ d->getDate (year, month, day, hour, min, sec);
240
+ Local<Date> date = Date::Cast (*Date::New (0.0 ));
241
+ CallDateMethod (date, " setSeconds" , sec);
242
+ CallDateMethod (date, " setMinutes" , min);
243
+ CallDateMethod (date, " setHours" , hour);
244
+ CallDateMethod (date, " setDate" , day);
245
+ CallDateMethod (date, " setMonth" , month - 1 );
246
+ CallDateMethod (date, " setFullYear" , year);
247
+ return date;
248
+ }
249
+
250
+ Local<Date> OracleTimestampToV8Date (oracle::occi::Timestamp* d) {
251
+ int year;
252
+ unsigned int month, day;
253
+ d->getDate (year, month, day);
254
+ Local<Date> date = Date::Cast (*Date::New (0.0 ));
255
+ CallDateMethod (date, " setSeconds" , 0 );
256
+ CallDateMethod (date, " setMinutes" , 0 );
257
+ CallDateMethod (date, " setHours" , 0 );
258
+ CallDateMethod (date, " setDate" , day);
259
+ CallDateMethod (date, " setMonth" , month - 1 );
260
+ CallDateMethod (date, " setFullYear" , year);
261
+ return date;
262
+ }
263
+
199
264
Local<Object> Connection::CreateV8ObjectFromRow (ExecuteBaton* baton, row_t * currentRow) {
200
265
Local<Object> obj = Object::New ();
201
266
uint32_t colIndex = 0 ;
@@ -217,9 +282,33 @@ Local<Object> Connection::CreateV8ObjectFromRow(ExecuteBaton* baton, row_t* curr
217
282
delete v;
218
283
}
219
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 ;
220
309
default :
221
310
std::ostringstream message;
222
- message << " Unhandled type: " << col->type ;
311
+ message << " CreateV8ObjectFromRow: Unhandled type: " << col->type ;
223
312
throw NodeOracleException (message.str ());
224
313
break ;
225
314
}
0 commit comments