[原]EAS动态扩展平台(DEP)服务端调用oracle存储过程
1、数据库上的存储过程
CREATE OR REPLACE PROCEDURE "XM_PRO_TEST" ( coding varchar2 -- 编码 ) IS -- 变量定义 BEGIN update T_IM_OtherInWarehsBill set FBaseStatus='4' where Fnumber=coding ; END XM_PRO_TEST;
2、EAS实体调用存储过程的方法
// 假设实体为:com.kingdee.eas.scm.im.inv.app.OtherIssueBill 方法为:String test0(String arg1) var imp = JavaImporter(); imp.importPackage(Packages.com.kingdee.eas.util.app); imp.importPackage(Packages.com.kingdee.bos); with(imp) { var ctx = pluginCtx.getContext(); //服务端上下文 var coding = methodCtx.getParamValue(0); //从客户端传来的参数 var conn = com.kingdee.bos.framework.ejb.EJBFactory.getConnection(ctx); // java.sql.Connection 数据库连接 var proc = conn.prepareCall("{ call XM_PRO_TEST(?) }"); // 参数准备 proc.setString(1, coding); // 添加参数 proc.execute(); //执行存储过程 } methodCtx.setResultValue("ABCD");
3、客户端调用服务端方法
var swingNames = JavaImporter(); swingNames.importPackage(Packages.com.kingdee.bos.ctrl.kdf.table.event); swingNames.importPackage(Packages.com.kingdee.eas.scm.common.client); swingNames.importPackage(Packages.com.kingdee.eas.util.app); // new add swingNames.importPackage(Packages.com.kingdee.bos); swingNames.importPackage(Packages.com.kingdee.eas.basedata.master.material); swingNames.importPackage(Packages.com.kingdee.bos.metadata.entity); swingNames.importPackage(Packages.com.kingdee.bos.metadata.query.util); swingNames.importPackage(Packages.com.kingdee.bos.metadata); swingNames.importPackage(Packages.com.kingdee.bos.util); swingNames.importPackage(Packages.com.kingdee.bos.util.client); swingNames.importPackage(Packages.com.kingdee.bos.framework); var tblMain = pluginCtx.getKDTable("kdtEntry"); with (swingNames) { var entry = pluginCtx.getKDTable("kdtEntry"); var rowCounts = entry.getRowCount(); var isValid = true; var strMess = "TR360902000024"; var work = null; var PK = new MetaDataPK("com.kingdee.eas.scm.im.inv.app.OtherIssueBill"); var methodName = "String test0(String arg1)"; var param = [strMess]; var result = BOClientTool.callCmethod(PK, methodName, param); }