condition=matcher.group(2);
backupSql.append("INSERT INTO "+tableName+" (");
}else{
matcher =patternTableName2.matcher(sql);
if(matcher.find()){
tableName=matcher.group(1);
condition=" 1=1";
backupSql.append("INSERT INTO "+tableName+" (");
}else{
backupSql.append("INSERT INTO NoTable (");
}
}
if(tableName!=null){
deleteSQL="DELETE FROM "+tableName+" WHERE "+condition+";\n";
}
for(i=0;i
}
backupSql.append(") VALUES (");
String columnsSQL = backupSql.toString().replace(",)", ")");
backupSql.setLength(0);
if(deleteSQL!=null){
backupSql.append(deleteSQL);
}
for(i=0;i
map = (Map)resultList.get(i);
o = map.get(columns.get(0));
if(o!=null){
backupSql.append(getValueString(o));
}else{
backupSql.append("''");
}
for(j=1;j
if(o!=null){
backupSql.append(","+getValueString(o));
}else{
backupSql.append(",''");
}
}
backupSql.append(");\n");
}
CommonUtils.saveFile(null, downloadPath+"sources/"+q.getScriptFileName()+".sql", backupSql.toString(),true);
/*CommonQueryResp resp = new CommonQueryResp();
resp.setTotalNum(resultSize);
resp.setResultList(resultList);
resp.setColumns(columns);
String resultMessage = JSONObject.fromObject(resp).toString();
CommonUtils.saveFile(null, downloadPath+"query.log", resultMessage,false);*/
}
public String getValueString(Object o) throws SQLException{
String columnType = o.getClass().toString();
if("class java.lang.String".equals(columnType)){
}else if("class java.math.BigDecimal".equals(columnType)){
return "'"+((java.math.BigDecimal) o).toString()+"'";
}
else if("class java.sql.Timestamp".equals(columnType)){
return "to_date('"+ CommonUtils.formatDate((java.sql.Timestamp) o)+"', 'yyyy-mm-dd')";
}else if("class oracle.sql.CLOB".equals(columnType)){
return "'"+((oracle.sql.CLOB)o).getSubString(1, (int)((oracle.sql.CLOB)o).length())+"'";
}
return "''";
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public String createFLZL(String[] sqls){
HashMap
StringBuffer bf = new StringBuffer();
int listLen;
for(String s:sqls){
requestMap.put("sql", s);
List