OAF_开发系列29_实现OAF中批次处理迭代器RowSet/RowSetIterator(案例)
20150814 Created By BaoXinjian
一、摘要
在Oracle官方指南和例子中,一般遍历记录,都是通过RowSetIterator的方式进行,RowSetIterator的用法,通过为VO创建一个迭代器来 循环每一个行
但在实际应用也可以通过Row和Rowset的方式进行遍历记录
具体情况具体分析
1. 选中记录和记录集合的三种方式
(1). 通过Row选中第一条记录:vo.getFirstFilteredRow("SelectFlag", new String("Y"));
(2). 通过RowSet选中所有被选中的记录:vo.getFiterredRow("SelectFlag", new String("Y"));
(3). 通过RowSetIterator选中所有记录:vo.createRowSetIterator("selectIter");
二、实施分析
Step1. 创建CO中的方法
(1). vo.getFirstFilteredRow("SelectFlag", new String("Y"));
(2). vo.getFiterredRow("SelectFlag", new String("Y"));
(3). vo.createRowSetIterator("selectIter");
Step2. 在CO具体控制代码,分析三种选中方案
public void processFormRequest(OAPageContext pageContext,
OAWebBean webBean) {
super.processFormRequest(pageContext, webBean);
try {
EmpManageAMImpl am = (EmpManageAMImpl)pageContext.getApplicationModule(webBean);
EmployeesItaraterVOImpl vo = am.getEmployeesItaraterVO();
//方案1. 通过ROW获取第一个选中栏位
if ("select".equals(pageContext.getParameter(EVENT_PARAM))) {
EmployeesItaraterVORowImpl row = (EmployeesItaraterVORowImpl) vo.getFirstFilteredRow("SelectFlag", new String("Y")); //获取记录集合
System.out.println("RowFirstEmployeeId=" + row.getEmployeeId());
}
//方案2. 通过ROWSET获取所有选中栏位
if ("select".equals(pageContext.getParameter(EVENT_PARAM))) {
Row[] rowset = vo.getFilteredRows("SelectFlag", new String("Y")); //获取记录集合
for (int i = 0; i < rowset.length; i++) {
EmployeesItaraterVORowImpl row = (EmployeesItaraterVORowImpl)rowset[i]; //取得当前记录
System.out.println("RowsetEmployeeId=" + row.getEmployeeId());
}
}
//方案3. 通过RowSetIterator所有选中栏位
if ("select".equals(pageContext.getParameter(EVENT_PARAM))) {
int rowcount = vo.getFetchedRowCount(); //取当前提取的记录集的记录数
RowSetIterator selectIter = vo.createRowSetIterator("selectIter"); //建立记录集的指示器
if (rowcount > 0) {
selectIter.setRangeStart(0); //设置循环起点,相当于移动指针到第一条记录
selectIter.setRangeSize(rowcount); //设置循环次数
for (int i = 0; i < rowcount; i++) {
EmployeesItaraterVORowImpl row = (EmployeesItaraterVORowImpl)selectIter.getRowAtRangeIndex(i); //取得当前记录
System.out.println("ItaraterEmployeeId=" + row.getEmployeeId());
}
}
selectIter.closeRowSetIterator();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
三、测试运行
Step1. 选中一条记录测试三种选中方式
Step2. 显示记录如下
Step3. 选中全部记录测试显示选中方式
Step4. 显示记录如下
Thanks and Regards
ERP技术讨论群: 288307890
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建
标签:
OAF
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
2014-07-25 BPEL_Oracle BPEL新一代工作流介绍(概念)
2014-07-25 DBA_Oracle基本体系架构(概念)