DEP中执行SQL语句案例分享
金蝶云社区-云社区用户Z4cW8528
云社区用户Z4cW8528
1人赞赏了该文章 1,621次浏览 未经作者许可,禁止转载编辑于2019年12月25日 11:40:41
在客户端脚本,只能查询,sql写法如下: var imp = JavaImporter(); imp.importPackage(Packages.com.kingdee.eas.util.app); imp.importPackage(Packages.java.sql); imp.importPackage(Packages.com.kingdee.eas.util.client);imp.importPackage(Packages.com.kingdee.bos.dao.query); with(imp){ var ctx = pluginCtx.getUIContext(); var editData = pluginCtx.getDataObject();if(pluginCtx.getOprtState().equals("EDIT")){var billId=editData.getId();var sql = "select count(*) as fjs from T_BAS_BoAttchAsso where FBOID='"+billId+"'"; var se=new SQLExecutor(sql);var rows = se.executeSQL();while ( rows. next ( ) ) { var fujian= rows.getInt("fjs"); } if(fujian==0){com.kingdee.eas.util.client.MsgBox.showInfo("附件数不能为0");com.kingdee.eas.util.SysUtil.abort();}} } 服务端扩展脚本,可以执行查询、修改的sql语句 修改语句写法如下:var imp = JavaImporter(); imp.importPackage(Packages.com.kingdee.eas.util.app);with(imp){ var ctx = pluginCtx.getContext(); var billId =methodCtx.getParamValue(0).getId(); var status ="13923772024"; var sql = "updateCT_CUS_Cunhuodan SET cflink = " +status + " WHERE FID = '"+billId+"'"; DbUtil.execute(ctx, sql); } 查询的写法如下:var imp = JavaImporter(); imp.importPackage(Packages.com.kingdee.eas.util.app); with(imp){ var ctx = pluginCtx.getContext(); var billId =methodCtx.getParamValue(0).getId(); var status ="13923772024"; var sql = "select cflink aslink from CT_CUS_Cunhuodan WHERE FID = '"+billId+"'"; varrow=DbUtil.executeQuery(ctx,sql);while ( row . next ( ) ) { var link= row . getString ( "link" ) ; } }