是脚本有问题吗?
下面是脚本内容:
var fgrid1 = getData("硅料季度产能");
var fgrid2 = getViewData("硅料季度产能");
//获取填报人
var submit_by = TUSER.getSelectedObjects()[0];
var Errorflag = "0";
var rowsOld = fgrid1.rows(ORIGINAL);
var rowsAdded = fgrid1.rows(ADDED);
var rowsChanged = fgrid1.rows(MODIFIED);
var rowsDeleted = fgrid1.rows(DELETED);
var ww=param['_USER_WORKGROUP']
var tel=param['TEL']
if (len(tel)==0 || len(tel) !=11 || substring(tel,0,1)!=1){
debug('电话输入错误,请重新输入')
}else {
if(rowsChanged[0]!=null){
debug("请上传更新");
}else if(rowsDeleted[0]!=null){
debug("请联系管理员删除底层数据");
}else if(rowsAdded[0]!=null){
debug("请上传新增");
}else{
var conn = null;
try {
conn = createConnection(CONNECTION, "YXBI");
var pstmt = conn.prepareStatement("UPDATE MANUAL_GF_QGLCN SET VERSION=VERSION+1 WHERE YDATE=? AND INCHAIN=? AND CORP_NAME=?");
var pstmt1 = conn.prepareStatement("INSERT INTO MANUAL_GF_QGLCN (YDATE,INCHAIN,CORP_NAME,CAPAC,CAPAC_SIME,CAPAC_SIPA,CAPAC_Q1,CAPACSIME_Q1,CAPACSIPA_Q1,CAPAC_Q2,CAPACSIME_Q2,CAPACSIPA_Q2,CAPAC_Q3,CAPACSIME_Q3,CAPACSIPA_Q3,CAPAC_Q4,CAPACSIME_Q4,CAPACSIPA_Q4,CAPAC_CP,CAPACSIME_CP,CAPACSIPA_CP,CAPAC_PB,CAPACSIME_PB,CAPACSIPA_PB,FILLED_BY,DATA_MAN_DEPT,DATA_MAN_TEL,FILLED_TIME) select ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,sysdate from dual");
for(var i = 1; i < fgrid2.size(); i++){
pstmt.setString(1, fgrid2.get(i,1));
pstmt.setString(2, fgrid2.get(i,0));
pstmt.setString(3, fgrid2.get(i,2));
pstmt.execute();
}
for(var i = 1; i < fgrid2.size(); i++){
pstmt1.setString(1, fgrid2.get(i,1));
pstmt1.setString(2, fgrid2.get(i,0));
pstmt1.setString(3, fgrid2.get(i,2));
pstmt1.setString(4, fgrid2.get(i,3));
pstmt1.setString(5, fgrid2.get(i,4));
pstmt1.setString(6, fgrid2.get(i,5));
pstmt1.setString(7,fgrid2.get(i,6));
pstmt1.setString(8, fgrid2.get(i,7));
pstmt1.setString(9, fgrid2.get(i,8));
pstmt1.setString(10, fgrid2.get(i,9));
pstmt1.setString(11, fgrid2.get(i,10));
pstmt1.setString(12, fgrid2.get(i,11));
pstmt1.setString(13, fgrid2.get(i,12));
pstmt1.setString(14, fgrid2.get(i,13));
pstmt1.setString(15, fgrid2.get(i,14));
pstmt1.setString(16, fgrid2.get(i,15));
pstmt1.setString(17, fgrid2.get(i,16));
pstmt1.setString(18, fgrid2.get(i,17));
pstmt1.setString(19,fgrid2.get(i,18));
pstmt1.setString(20, fgrid2.get(i,19));
pstmt1.setString(21, fgrid2.get(i,20));
pstmt1.setString(22, fgrid2.get(i,21));
pstmt1.setString(23, fgrid2.get(i,22));
pstmt1.setString(24, fgrid2.get(i,23));
pstmt1.setString(25, submit_by);
pstmt1.setString(26, ww);
pstmt1.setString(27, tel);
pstmt1.setString(28, fgrid2.get(i,1));
pstmt1.execute();
}
}catch(e){
try {
if(conn != null) {
conn.rollback();
}
}catch(e1) { }
debug("Update DataBase Error: " + e);
debug("上传数据存在格式不正确情况,本次提交失败,请检查后提交");
Errorflag = "1";
}finally {
if(conn != null) {
try {
conn.commit();
conn.close();
if(Errorflag == "1"){
debug("执行结果:失败");
}
else{
debug("执行结果:成功");
}
}catch(e2) {}
}
}
}
refreshData();
}
|