Java快速开发如何执行存储过程(带参)

来源:互联网 发布:网络老虎机辅助软件 编辑:程序博客网 时间:2024/05/29 14:42
import java.util.List;
import com.egosystems.dbcore.CommandType;
import com.egosystems.dbcore.DBGetResult;
import com.egosystems.dbcore.DMLType;
import com.egosystems.dbcore.DataTable;
import com.egosystems.dbcore.ParameterDirection;
import com.egosystems.dbcore.Parm_Struct;

/**表单相关事件 - 不可修改名称
* 保存后事件
* @author egosystems
*/
public void onAfterSave() throws Exception
{
    String 参数1 = This.Parameters.get("text_参数1");            //获得页面上的值
    String 参数2 = This.Parameters.get("text_参数2");            //获得页面上的值
    Parm_Struct tmp1 = new Parm_Struct(参数1);
    Parm_Struct tmp2 = new Parm_Struct(参数2);
    List<Parm_Struct> ParamSp = new ArrayList<Parm_Struct>();
    ParamSp.add(tmp1);                            //参数1添加进数组
    ParamSp.add(tmp2);                            //参数2添加进数组
    This.dbgr.GetDataTable("p_存储过程名",CommandType.PROC,ParamSp);    //执行存储过程(存储过程名,SQL类型,参数)
}
 
*********************************************************************************************
 
注如果是ORACLE一定要注意过程中需要返回记录集游标

create or replace procedure  sp_testPROC
(
param1 varchar2,
p_cursor    in out ego.cursorType
--,p_cursor2,p_cursor3
) as
begin
 
  open p_cursor for
    select *  from sys_user;
end ;

注:最多返回3个记录集
如果返回超过1个以上的记录集需要在dbgr里面指定,代码如下:
dbgr.ResultNum = 2;