OAF_开发系列29_实现OAF中批次处理迭代器RowSet/RowSetIterator(案例)

简介: 20150814 Created By BaoXinjian 一、摘要 在Oracle官方指南和例子中,一般遍历记录,都是通过RowSetIterator的方式进行,RowSetIterator的用法,通过为VO创建一个迭代器来 循环每一个行 但在实际应用也可以通过Row和Rowset的方式进行遍历记录 具体情况具体分析   1.

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 - 鲍新建
相关文章
|
存储 Oracle 关系型数据库
oracle服务器存储过程中调用http
通过配置权限、创建和调用存储过程,您可以在Oracle数据库中使用UTL_HTTP包发起HTTP请求。这使得Oracle存储过程可以与外部HTTP服务进行交互,从而实现更复杂的数据处理和集成。在实际应用中,根据具体需求调整请求类型和错误处理逻辑,以确保系统的稳定性和可靠性。
761 0
|
XML 数据格式
HttpServletRequest的介绍和方法以及代码实战
HttpServletRequest的介绍和方法以及代码实战
942 0
|
存储 自然语言处理 JavaScript
vben框架是什么
vben框架是什么
3020 0
解决requried a bean of type xxx的问题(可能原因之一)
解决requried a bean of type xxx的问题(可能原因之一)
809 0
|
存储 安全 Java
【Java中的Vector详解】
【Java中的Vector详解】
195 0
|
关系型数据库 Oracle
LOB字段存放在指定表空间 清理CLOB字段及压缩CLOB空间
LOB字段存放在指定表空间 清理CLOB字段及压缩CLOB空间    把LOB字段的SEGMENT 存放在指定表空间、清理CLOB字段及压缩CLOB空间 1、创建LOB字段存放表空间:create tablespace lob_test datafile '/oracle/data/lob_test.
3637 0