Updating the same record in database based on the for loop
<p>I have this case where a document with status F, needs to be saved in table LOGS, with the name of the file.</p>

<p>My table should have the following representation:</p>

<pre><code>ID: Incremented
FILE:  fileNameWithOutExt (name of the file)
ERROR: errorCode
</code></pre>

<p>However all the documents within the same file having the same status, need to be inserted in the same record as so:</p>

<pre><code>ID: 1
FILE:test
ERROR: id:5,id:9,id:10
</code></pre>

<p>My if status statement is within a for loop that's passing on all children in an xml file. The ones with status F need to be concatenated within the same record.</p>

<pre><code>if(status.equals("F")){
    elemValue = element.getChild("id").getValue();
    String fileNameWithExt = f.getName();
    String fileNameWithOutExt = FilenameUtils.removeExtension(fileNameWithExt);
    saveLogs(fileNameWithOutExt, elemValue);
}

private void saveLogs(String fileNameWithOutExt, String elemValue){
    String errorCode = "id:"+ elemValue;
    String query = "INSERT INTO LOGS (FILE,ERROR)VALUES ('"+fileNameWithOutExt+"','"+errorCode+"')";
    String content = "";
    content = SqlTool.selectOneString("DB", query);   
}
</code></pre>