Oracle查询存储过程作为横向报告方法

Oracle查询存储过程作为横向报告方法
因为需要涉及两个小计,所以有必要进行计算。

思想:

1,将查询结果插入临时表中,

2,将统计结果插入临时表中。

3,查询临时表记录放置在游标中。

4,删除临时表记录。

包的定义声明:

复制代码代码如下所示:

创建包chen_test_packge是
cursor_type是REFCURSOR类型;
************************************************************************************ / /
功能描述:一个查询/公告公告
参数说明: /
i_id_capital_dynamic_manage在VARCHAR2身份 / * * /通知
o_cursor / * cursor_type返回光标。

创建日期
路人2013-03-08 / * * /
************************************************************************************ / /

程序p_list_bulletin_report(i_id_capital_dynamic_manage在空,
o_cursor出cursor_type);

最后chen_test_packge;
软件包的实现:

复制代码代码如下所示:
创建包体chen_test_packge是

************************************************************************************ / /
功能描述:一个查询/公告公告
参数说明: /
i_id_capital_dynamic_manage在VARCHAR2身份 / * * /通知
o_cursor / * bulletin_report_type返回光标。

创建日期
路人2013-03-08 / * * /
************************************************************************************ / /

程序p_list_bulletin_report(i_id_capital_dynamic_manage在空,
o_cursor出bulletin_report_type)
作为
set_id_bulletin_report_temp VARCHAR2(50);定义临时变量
开始
开始
-临时变量的赋值
——选择to_char(SYSDATE,'yyyymmddhh24misssss)从双成set_id_bulletin_report_temp;
选择i_id_capital_dynamic_manage为set_id_bulletin_report_temp双;
-将数据插入到临时表中
插入scms_bulletin_report_temp

id_bulletin_report_temp,
biz_name,
T01,
T07,
T14,
T21,
T1M,
2米,
T3M,
T4M,
t5m,
T6M,
t1y,
t2y,
TCOUNT,
sort_no

选择C *,
行号为sort_no
(从
选择
set_id_bulletin_report_temp作为id_bulletin_report_temp,
scms_common_packge.get_biz_name(b.biz_id)作为biz_name,
马克斯(在b.term_type = 't01'then B、C其他0端)为T01,
马克斯(在b.term_type = 't07'then B、C其他0端)为T07,
马克斯(在b.term_type = 't14'then B、C其他0端)为T14,
马克斯(在b.term_type = 't21'then B、C其他0端)为T21,
马克斯(在b.term_type = 't1m'then B、C其他0端)为T1M,
马克斯(在b.term_type = 't2m'then B、C其他0端)为2米,
马克斯(在b.term_type = 't3m'then B、C其他0端)为T3M,
马克斯(在b.term_type = 't4m'then B、C其他0端)为T4M,
马克斯(在b.term_type = 't5m'then B、C其他0端)为t5m,
马克斯(在b.term_type = 't6m'then B、C其他0端)作为T6M,
马克斯(在b.term_type = 't1y'then B、C其他0端)为t1y,
马克斯(在b.term_type = 't2y'then B、C其他0端)为t2y,
和(公元前)为biz_id_count


选择a.term_type,a.biz_id,和(a.capital_claim)C
从report.capital_claim(选择,
report.biz_id,
detail.term_type
从scms_capital_claim_report报告,
scms_capital_assign_detail细节,
scms_capital_dynamic_manage经理
在manager.id_capital_dynamic_manage = detail.id_capital_dynamic_manage
和report.id_capital_assign_detail = detail.id_capital_assign_detail
和detail.id_capital_dynamic_manage = i_id_capital_dynamic_manage
和manager.is_settlement = 1
和manager.is_confirm = 1
一)
集团通过a.term_type,a.biz_id
通过b.biz_id B组)
C);

-插入记录总数
插入scms_bulletin_report_temp

id_bulletin_report_temp,
biz_name,
T01,
T07,
T14,
T21,
T1M,
2米,
T3M,
T4M,
t5m,
T6M,
t1y,
t2y,
TCOUNT,
sort_no

选择C *,
(选择最大(sort_no)+ 1 scms_bulletin_report_temp TE在te.id_bulletin_report_temp = set_id_bulletin_report_temp)作为sort_no
(从
选择
set_id_bulletin_report_temp作为id_bulletin_report_temp,
总(天)biz_name,
马克斯(在b.term_type = 't01'then B、C其他0端)为T01,
马克斯(在b.term_type = 't07'then B、C其他0端)为T07,
马克斯(在b.term_type = 't14'then B、C其他0端)为T14,
马克斯(在b.term_type = 't21'then B、C其他0端)为T21,
马克斯(在b.term_type = 't1m'then B、C其他0端)为T1M,
马克斯(在b.term_type = 't2m'then B、C其他0端)为2米,
马克斯(在b.term_type = 't3m'then B、C其他0端)为T3M,
马克斯(在b.term_type = 't4m'then B、C其他0端)为T4M,
马克斯(在b.term_type = 't5m'then B、C其他0端)为t5m,
马克斯(在b.term_type = 't6m'then B、C其他0端)作为T6M,
马克斯(在b.term_type = 't1y'then B、C其他0端)为t1y,
马克斯(在b.term_type = 't2y'then B、C其他0端)为t2y,
和(公元前)为biz_id_count


选择a.term_type,'biz_id_count'as biz_id,和(a.capital_claim)C
从report.capital_claim(选择,
report.biz_id,
detail.term_type
从scms_capital_claim_report报告,
scms_capital_assign_detail细节,
scms_capital_dynamic_manage经理
在manager.id_capital_dynamic_manage = detail.id_capital_dynamic_manage
和report.id_capital_assign_detail = detail.id_capital_assign_detail
和detail.id_capital_dynamic_manage = i_id_capital_dynamic_manage
和manager.is_settlement = 1
和manager.is_confirm = 1
一)
集团通过a.term_type
通过b.biz_id B组)
C);
-查询刚刚插入的表记录
打开o_cursor为
选择
id_bulletin_report_temp作为idbulletinreporttemp,
biz_name作为bizname,
T01为T01,
T07为T07,
T14为T14,
T21为T21,
T1M为T1M,
2米为2米,
T3M为T3M,
T4M为T4M,
t5m作为t5m,
作为T6M T6M,
t1y作为t1y,
t2y作为t2y,
TCOUNT作为TCOUNT,
sort_no作为sortno
从scms_bulletin_report_temp温度
在temp.id_bulletin_report_temp = set_id_bulletin_report_temp
通过sortno ASC秩序;
-删除:删除按ID插入的记录
从scms_bulletin_report_temp温度在temp.id_bulletin_report_temp = set_id_bulletin_report_temp删除;
承诺;
结束;
最后p_list_bulletin_report;
最后chen_test_packge;
/
网页调用ibatis的XML配置的查询结果:

复制代码代码如下所示:


{电话chen_test_packge.p_list_bulletin_report(,)}
java调用:

复制代码代码如下所示:
字符串id_capital_dynamic_manage = request.getparameter(id_capital_dynamic_manage );
图paramap =新HashMap();
ParaMap.put(i_id_capital_dynamic_manage
调用存储过程、查询
表resultlist =(表< >)curdutil.querylist(querybulletinreportlist
页面显示jsp:

复制代码代码如下所示:

tag:查询存储过程报告横向方法

相关内容