@@ -46,14 +46,16 @@ void ExecuteBaton::ResetValues() {
4646 delete (oracle::occi::Timestamp*)val->value ;
4747 break ;
4848 case VALUE_TYPE_ARRAY:
49- if (val->value != NULL && val->elemetnsType == oracle::occi::OCCI_SQLT_STR)
50- delete (char *)val->value ;
51- else if (val->value != NULL && val->elemetnsType == oracle::occi::OCCI_SQLT_NUM)
52- delete (char *)val->value ;
49+ arrayParam_t* arrParam = (arrayParam_t*)val->value ;
50+ if (arrParam->value != NULL && arrParam->elemetnsType == oracle::occi::OCCI_SQLT_STR)
51+ delete (char *)arrParam->value ;
52+ else if (arrParam->value != NULL && arrParam->elemetnsType == oracle::occi::OCCI_SQLT_NUM)
53+ delete (char *)arrParam->value ;
5354
54- if (val ->elementLength != NULL )
55- delete val ->elementLength ;
55+ if (arrParam ->elementLength != NULL )
56+ delete arrParam ->elementLength ;
5657
58+ delete (arrayParam_t*)val->value ;
5759 break ;
5860 }
5961 delete val;
@@ -150,7 +152,8 @@ void ExecuteBaton::CopyValuesToBaton(ExecuteBaton* baton, v8::Local<v8::Array>*
150152 else if (val->IsArray ()) {
151153 value->type = VALUE_TYPE_ARRAY;
152154 Local<Array> arr = Local<Array>::Cast (val);
153- GetVectorParam (baton, value, arr);
155+ value->value = new arrayParam_t ();
156+ GetVectorParam (baton, (arrayParam_t*)value->value , arr);
154157 baton->values .push_back (value);
155158 }
156159
@@ -182,14 +185,14 @@ void ExecuteBaton::CopyValuesToBaton(ExecuteBaton* baton, v8::Local<v8::Array>*
182185 }
183186}
184187
185- void ExecuteBaton::GetVectorParam (ExecuteBaton* baton, value_t *value , Local<Array> arr) {
188+ void ExecuteBaton::GetVectorParam (ExecuteBaton* baton, arrayParam_t* arrParam , Local<Array> arr) {
186189 // In case the array is empty just initialize the fields as we would need something in Connection::SetValuesOnStatement
187190 if (arr->Length () < 1 ) {
188- value ->value = new int [0 ];
189- value ->collectionLength = 0 ;
190- value ->elementsSize = 0 ;
191- value ->elementLength = new ub2[0 ];
192- value ->elemetnsType = oracle::occi::OCCIINT;
191+ arrParam ->value = new int [0 ];
192+ arrParam ->collectionLength = 0 ;
193+ arrParam ->elementsSize = 0 ;
194+ arrParam ->elementLength = new ub2[0 ];
195+ arrParam ->elemetnsType = oracle::occi::OCCIINT;
193196 return ;
194197 }
195198
@@ -199,7 +202,7 @@ void ExecuteBaton::GetVectorParam(ExecuteBaton* baton, value_t *value, Local<Arr
199202
200203 // String array
201204 if (val->IsString ()) {
202- value ->elemetnsType = oracle::occi::OCCI_SQLT_STR;
205+ arrParam ->elemetnsType = oracle::occi::OCCI_SQLT_STR;
203206
204207 // Find the longest string, this is necessary in order to create a buffer later.
205208 int longestString = 0 ;
@@ -215,7 +218,7 @@ void ExecuteBaton::GetVectorParam(ExecuteBaton* baton, value_t *value, Local<Arr
215218 // Create a long char* that will hold the entire array, it is important to create a FIXED SIZE array,
216219 // meaning all strings have the same allocated length.
217220 char * strArr = new char [arr->Length () * longestString];
218- value ->elementLength = new ub2[arr->Length ()];
221+ arrParam ->elementLength = new ub2[arr->Length ()];
219222
220223 // loop thru the arr and copy the strings into the strArr
221224 int bytesWritten = 0 ;
@@ -236,21 +239,21 @@ void ExecuteBaton::GetVectorParam(ExecuteBaton* baton, value_t *value, Local<Arr
236239 bytesWritten += longestString;
237240
238241 // Set the length of this element, add +1 for the '\0'
239- value ->elementLength [i] = utfStr.length () + 1 ;
242+ arrParam ->elementLength [i] = utfStr.length () + 1 ;
240243 }
241244
242- value ->value = strArr;
243- value ->collectionLength = arr->Length ();
244- value ->elementsSize = longestString;
245+ arrParam ->value = strArr;
246+ arrParam ->collectionLength = arr->Length ();
247+ arrParam ->elementsSize = longestString;
245248 }
246249
247250 // Integer array.
248251 else if (val->IsNumber ()) {
249- value ->elemetnsType = oracle::occi::OCCI_SQLT_NUM;
252+ arrParam ->elemetnsType = oracle::occi::OCCI_SQLT_NUM;
250253
251254 // Allocate memory for the numbers array, Number in Oracle is 21 bytes
252255 unsigned char * numArr = new unsigned char [arr->Length () * 21 ];
253- value ->elementLength = new ub2[arr->Length ()];
256+ arrParam ->elementLength = new ub2[arr->Length ()];
254257
255258 for (unsigned int i = 0 ; i < arr->Length (); i++) {
256259 Local<Value> currVal = arr->Get (i);
@@ -273,13 +276,13 @@ void ExecuteBaton::GetVectorParam(ExecuteBaton* baton, value_t *value, Local<Arr
273276 // Convert the JS number into Oracle Number and get its bytes representation
274277 oracle::occi::Number n = d;
275278 oracle::occi::Bytes b = n.toBytes ();
276- value ->elementLength [i] = b.length ();
279+ arrParam ->elementLength [i] = b.length ();
277280 b.getBytes (&numArr[i*21 ], b.length ());
278281 }
279282
280- value ->value = numArr;
281- value ->collectionLength = arr->Length ();
282- value ->elementsSize = 21 ;
283+ arrParam ->value = numArr;
284+ arrParam ->collectionLength = arr->Length ();
285+ arrParam ->elementsSize = 21 ;
283286 }
284287
285288 // Unsupported type
0 commit comments