Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9159

Re: HANA XS js problem

$
0
0

Hi,

Is it a bug?

I recently got the same problem. I use the following pseudo code to send an array of data records to one database:

 

 

...
var myDataRecords = [...];                  // array with data records
var myInsertQuery = 'INSET INTO ...';
prepSt = conn.prepareStatement(myInsertQuery);
if (myDataRecords.length > 0){     prepSt.setBatchSize(myDataRecords.length);     for(var i = 0; i < myDataRecords.length; i++){          prepSt.setInt(1, myDataRecords[i].dataField_1);          prepSt.setString(2, myDataRecords[i].dataField_2);          ...          prepSt.setString(n, myDataRecords[i].dataField_n);          prepSt.addBatch();     }     prepSt.executeBatch();     
}
prepSt.close();
...

It works fine but if the data record array has only one record this code trows exception at addBatch():

"PreparedStatement.addBatch: bulk insert not enabled".

Is a batching with a batch size = 1 a special case?  The special cases make a code ugly. .

Please tell me that I am wrong.


Viewing all articles
Browse latest Browse all 9159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>