sFieldValue=request.getParameter(fieldname.toLowerCase());
//若表单未提交该字段的值,则忽略该字段的处理
if((sFieldValue!=null)){
//生成insert语句=insSql1+insSql2 即insert into tablename(… 和 values(…
if(OperType.equals("insert")){
insSql1+=fieldname+",";
if(Datatype.equals("DATE")){
insSql2+= "To_Date(’" + sFieldValue + "’,’YYYY-MM-DD’),";
}
else if(Datatype.equals("VARCHAR2") || Datatype.equals("CHAR")){
insSql2+="’" + sFieldValue+"’,";
}else /*NUMBER, FLOAT*/ insSql2+= sFieldValue+",";}
//生成update语句=updateSql+whereSql 即update tablename set ... where fieldname=...
if(OperType.equals("update")){
if(Datatype.equals("DATE")){
updateSql+=fieldname+"=To_Date(’" + sFieldValue + "’,’YYYY-MM-DD’),";
}else if(Datatype.equals("VARCHAR2") || Datatype.equals("CHAR")){
updateSql+=fieldname+"=’" + sFieldValue,1}+"’,";
}
else /*NUMBER, FLOAT*/ updateSql+=fieldname+"="+sFieldValue+",";} ))
rs1.close();
文章来源于领测软件测试网 https://www.ltesting.net/