标签:des cWeb style class blog code
2014-06-22 BaoXinjian
一、摘要
在Report Builder中,有两种数据源取法,一种是基于SQL的,另外一种就是基于Ref Cursor的写法
Ref Cursor在Report Builder 中主要用于一些公用的查询会使用到
比如有多个Report可能会用到同一段SQL或者类似SQL,一般会将这个SQL独立出来作为Ref Cursor放在Package中
当Report调用时,就可以通过调用package中的ref cursor实现查询,而不是讲这段SQL每个report都重复写一遍,当SQL需修改时,也只需改Package中的ref cursor即可
在调用Ref Cursor时,
二、分步解析
案例: 定义一个Employee信息获取公用Ref-Cursor,该查询定义在Package中,可被多个report builder调用共享
Step1. 定义了两种类型的ref_cursor,
/*定义ref cursor package头*/ CREATE OR REPLACE PACKAGE bxj_ref_cursor_pkg IS TYPE employee_rec IS RECORD( user_id FND_USER.USER_ID%TYPE, employee_num HR_EMPLOYEES.EMPLOYEE_NUM%TYPE, user_name FND_USER.USER_NAME%TYPE, party_type HZ_PARTIES.PARTY_TYPE%TYPE, prefix HR_EMPLOYEES.PREFIX%TYPE, full_name HR_EMPLOYEES.FULL_NAME%TYPE); TYPE employee_refcursor IS REF CURSOR RETURN employee_rec; FUNCTION query_employee(user_id NUMBER) RETURN bxj_ref_cursor_pkg.employee_refcursor; END;
Step2. 定义ref_cursor查询体的如何返回
1 /*定义ref cursor package 体*/ 2 CREATE OR REPLACE PACKAGE BODY bxj_ref_cursor_pkg IS 3 4 FUNCTION query_employee(user_id number) 5 RETURN bxj_ref_cursor_pkg.employee_refcursor IS 6 temp_employee_cursor bxj_ref_cursor_pkg.employee_refcursor; 7 BEGIN 8 9 OPEN temp_employee_cursor FOR 10 SELECT user_id, employee_num, user_name, party_type, prefix, full_name 11 FROM fnd_user fu, hz_parties hp, hr_employees he 12 WHERE fu.person_party_id = hp.party_id 13 AND hp.person_identifier = he.employee_id 14 AND fu.user_name = ‘GAVIN‘; 15 16 RETURN temp_employee_cursor; 17 18 END; 19 20 END;
Step3. 在report builder中的两种Query (SQL Query和Ref Cursor Query)
Step4. Query触发器中返回Ref Cursor结构体
********************作者: 鲍新建********************
Report_报表中Ref Cursor数据源的概念和用法(案例),布布扣,bubuko.com
Report_报表中Ref Cursor数据源的概念和用法(案例)
标签:des cWeb style class blog code
原文地址:http://www.cnblogs.com/eastsea/p/3802394.html