标签:
1、包头:
CREATE OR REPLACE PACKAGE BAWQ_PROC_PAGE IS -- BAWQ_PROC_PAGE 是包头名 TYPE T_CURSOR IS REF CURSOR; --动态游标 PROCEDURE PROC_PAGE --存储过程名字 ( CS_ZB IN INT :=20, pageNumber IN INT, pageSize IN INT, SUM1 out INT , p_ReCursor0 out T_CURSOR ); END BAWQ_PROC_PAGE;
2、包体:
CREATE OR REPLACE PACKAGE BODY BAWQ_PROC_PAGE IS PROCEDURE PROC_PAGE ( CS_ZB IN INT :=20, pageNumber IN INT, pageSize IN INT, SUM1 out INT , p_ReCursor0 out T_CURSOR ) IS BEGIN if pageNumber is not null and pageSize is not null then select COUNT(1) into SUM1 from ( select YJ 省,EJ 市,SJ 县,SZ1 今年销售额,SZ2 去年销售额 FROM SZQCSBJ WHERE CS_ZB>10 union all select YJ 省,EJ 市,SJ 县,SZ1 今年销售额,SZ2 去年销售额 FROM SZQCSBJ WHERE CS_ZB>10 UNION ALL select ‘省‘,‘市‘,‘县‘,-120 今年销售额,-120 去年销售额 from dual WHERE CS_ZB>10 union all select ‘省‘,‘市‘,‘县‘,null 今年销售额,null 去年销售额 from dual WHERE CS_ZB>10 union all select ‘省‘,‘市‘,‘县‘,0 今年销售额,0 去年销售额 from dual WHERE CS_ZB>10 )aaa; open p_ReCursor0 for select 省,市,县,今年销售额,去年销售额 from ( select rownum rownumber,A.* from ( select YJ 省,EJ 市,SJ 县,SZ1 今年销售额,SZ2 去年销售额 FROM SZQCSBJ WHERE CS_ZB>10 union all select YJ 省,EJ 市,SJ 县,SZ1 今年销售额,SZ2 去年销售额 FROM SZQCSBJ WHERE CS_ZB>10 UNION ALL select ‘省‘,‘市‘,‘县‘,-120 今年销售额,-120 去年销售额 from dual WHERE CS_ZB>10 union all select ‘省‘,‘市‘,‘县‘,null 今年销售额,null 去年销售额 from dual WHERE CS_ZB>10 union all select ‘省‘,‘市‘,‘县‘,0 今年销售额,0 去年销售额 from dual WHERE CS_ZB>10 )A )B WHERE rownumber between (pageNumber-1) *pageSize+1 AND pageNumber*pageSize; else open p_ReCursor0 for select YJ 省,EJ 市,SJ 县,SZ1 今年销售额,SZ2 去年销售额 FROM SZQCSBJ WHERE CS_ZB>10 union all select YJ 省,EJ 市,SJ 县,SZ1 今年销售额,SZ2 去年销售额 FROM SZQCSBJ WHERE CS_ZB>10 UNION ALL select ‘省‘,‘市‘,‘县‘,-120 今年销售额,-120 去年销售额 from dual WHERE CS_ZB>10 union all select ‘省‘,‘市‘,‘县‘,null 今年销售额,null 去年销售额 from dual WHERE CS_ZB>10 union all select ‘省‘,‘市‘,‘县‘,0 今年销售额,0 去年销售额 from dual WHERE CS_ZB>10; end if; END PROC_PAGE; END BAWQ_PROC_PAGE;
标签:
原文地址:http://www.cnblogs.com/SunBlog/p/4904817.html