Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Fileupload: Allocation Size Overflow

$
0
0

Hi Thomas

 

I have read a little bit into the thematics and I see the problem... Looks like I need to explain it a little more.

 

What I am doing in XSJS is a bit more complicated than just a simple insert. I tried to create a generic CSV-File upload. The files are being checked for errors, the header line is being read and checked if all the columns in the database table can be found in the file headers. (This includes matching, so the columns in the file don't need to be in order).I am also using the batch-load functionalities.

 

I tried taking out the important part. There is done a lot of prework like splitting the file content into rows, checkinf the header row, creating a prepared statement and so on...

 

//file_rows inclused all rows in an array
pstmt.setBatchSize(file_rows.length - 1);
ignored = 0;
for(i = 1; i < file_rows.length; i++){    //the fields are being split by the delimiters and the enclosed character    fields = file_rows[i].split(enclosedby + splitby + enclosedby);    //check for right number of columns (invalid CSV-files)    if(fields.length !== file_header.length){        throw "Invalid number of columns at line " + (i + 1) + "\n";    }    //for each value in the row (includes column matching)    for(dbpos = 0; dbpos < fields.length; dbpos++){        if(cols.indexOf(file_header[dbpos]) !== -1){            //check if numeric columns            if(file_header[dbpos] === "Annualized Revenue" || file_header[dbpos] === "EXP_REV_EUR"){                pstmt.setDouble(cols.indexOf(file_header[dbpos]) + 1,parseFloat(fields[dbpos].replace("'","").replace(",","")));            }else{                pstmt.setNString(cols.indexOf(file_header[dbpos]) + 1,fields[dbpos]);            }        }else{            ignored++;        }    }    pstmt.addBatch();
}
affectedrows = pstmt.executeBatch();

As I saw from your link, it would be better to use an array instead of a normal string due to memory assignment. What about this case? I can't see a case where I would use a string that could make problems...


Viewing all articles
Browse latest Browse all 9165

Trending Articles



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