I am doing a batch insert in SAP HANA and below is my code:
for (int i = 1; i <= ITERATION_MAX; i++) {
String arraylist=Arrays.toString(listofdata.get(i).get_arraylist.replace("[","").replace("]",""));
id=listofdata.get(i).get_id();
name= listofdata.get(i).get_name();
place=listofdata.get(i).get_place();
year= listofdata.get(i).get_year();
day=listofdata.get(i).get_day();
rollno= listofdata.get(i).get_rollno();
main_subject= listofdata.get(i).get_main_subject();
elective= listofdata.get(i).get_elective();
Statement stmt = conn.createStatement();
String sql="INSERT INTO SCHEMA.TABLE values("+
+name+","
place+","
year+day+","
rollno+","
main_subject+","
elective"+","
"ARRAY("+arraylist+")" ;
stmt.addbatch(sql);
}
stmt.executeBatch();
stmt.close();
conn.commit();
conn.close();
The code works fine but it fails sometimes and the error shows
sql statement too long.
So because of this my whole batch(10000 rows) fails and I don't want to face. It will be good if I can know the maximum SQL statement length that I can use.
have something like
if (sql.length()<max_length){
stmt.addbatch(sql);
}
else{
}
But I wanted to make sure that is the maximum length. Any help is appreciated