create or replace package abc_zys is
procedure daily_census;
end abc_zys;
--建乙個包,包中有儲存過程daily_census。不涉及任何引數。
create or replace package body abc_zys is
procedure daily_census as
type t_cursor is ref cursor;
r t_cursor; ——建立動態游標
v_tablename varchar2(30) := 'abc_check_';
v_tablename2 varchar2(30) := 'abcre_check_';
isp_id number;
sum_a number;
sum_b number;
send_cmpp number;
send_cmpp_success number;
send_sgip number;
send_sgip_success number;
send_smgp number;
send_smgp_success number;
send_cmpp_95599 number;
send_cmpp_su95 number;
send_sgip_95599 number;
send_sgip_su95 number;
send_smgp_95599 number;
send_smgp_su95 number;
v_sql varchar2(4000);
v_content varchar2(4000);
v_sql2 varchar2(4000);
begin
v_tablename := v_tablename || to_char(sysdate - 1,'mmdd');
v_tablename2 := v_tablename2 || to_char(sysdate - 1,'mmdd');
v_sql := 'select isp_id,sum(a),sum(b) from (
select isp_id,sum(msg_count) a,sum(case when send_status=''01'' then msg_count else 0 end) b from '||v_tablename||' t group by isp_id union all
select isp_id,sum(msg_count),sum(case when send_status=''01'' then msg_count else 0 end) from abcre_log.'||v_tablename2||' t group by isp_id)
group by isp_id';
open r for v_sql; ——用游標遍歷上述sql語句
loop
fetch r
into isp_id, sum_a, sum_b;
exit when r%notfound;
case
when isp_id=0 then
send_cmpp:=sum_a;
send_cmpp_success:=sum_b;
when isp_id=1 then
send_sgip:=sum_a;
send_sgip_success:=sum_b;
when isp_id=3 then
send_smgp:=sum_a;
send_smgp_success:=sum_b;
when isp_id=7 then
send_smgp_95599:=sum_a;
send_smgp_su95:=sum_b;
when isp_id=8 then
send_sgip_95599:=sum_a;
send_sgip_su95:=sum_b;
end case;
end loop;
close r;
v_sql2:= 'select sum(msg_count) ,sum(case when send_status=''01'' then msg_count else 0 end) from abcmas_log.'||v_tablename2||' t' ;
execute immediate v_sql2 into send_cmpp_95599,send_cmpp_su95;
v_content:='您好,'||to_char(sysdate - 1,'mmdd')||'日 1069移動 總數 '||send_cmpp||'; 成功數 '||send_cmpp_success
||';1069電信 總數: '||send_smgp||'; 成功數:'|| send_smgp_success||'; 1069聯通 總數: '||send_sgip||';成功數: '
||send_sgip_success||'; 95599聯通 總數: '||send_sgip_95599||';成功數: '||send_sgip_su95||';95599電信 總數: '||
send_smgp_95599||';成功數: '||send_sgip_su95||'.'||'95599移動(mas)總數: '||send_cmpp_95599||';成功數: '||send_cmpp_su95||'.';
abc_job.writewaitdatato216('13621193249',v_content,0);
end daily_census;
end abc_zys;
乙個儲存過程
首先是建立儲存過程.drop procedure if exists externalcalltocomplete delimiter create procedure externalcalltocomplete begin drop table if exists temp1 create ta...
乙個分頁儲存過程
page language c import namespace system.data import namespace system.data.sqlclient 訂單號 服務專案 預訂日期 操作人員 分配狀態 databinder.eval container.dataitem,offerid...
乙個分頁儲存過程
louje 分頁儲存過程 create procedure usp page pagesize int,頁大小 pageno int,頁號 tablename nvarchar 500 表名 keyword nvarchar 20 主鍵 fieldname nvarchar 2000 要顯示的欄位名...