在客户端脚本,只能查询,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 = "update CT_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 as link from CT_CUS_Cunhuodan WHERE FID = '"+billId+"'";
var row=DbUtil.executeQuery(ctx,sql);
while ( row . next ( ) )
{ var link= row . getString ( "link" ) ; }
}
另外,第三个附件,dep执行SQL案例里面写的,客户端只能执行查询;
我补充下客户端执行增删改SQL的方法:
案例:
var data_update_sql = "update T_EC_ResourceItem c set CFmaterialID = '"+materialId+"' where c.fid = '"+resourceMaterialId+"' ";
com.kingdee.eas.csinterface.syncdatabase.SQLFacadeFactory.getRemoteInstance().exeSQL(data_update_sql);
这个方法适用客户端的增删改SQL语句
推荐阅读