帮忙解释下下面的SQL语句什么意思(分数献上)

wx358165717 2010-04-20 06:58:29
在电信的同学说这个是视图,但是不懂,请有学问的各位大神来解释下
谢谢


create or replace procedure coll.coll_stop3_accounts_proc
/*
author: xuyuqing
date: 2006.12.26
use for: to get the accounts who have been suspended over three month,
the data will be provided to print center
*/
is
v_control_seq number;
v_account_no number(15);
v_crm_complete_date date;
v_detail_seq number(11);
v_total_cnt number;
v_cnt number;
v_flag number;
v_msg number;
v_err varchar2(500);

cursor get_stop_cur is
select to_number(a.account_no),b.crm_complete_date
from coll_suspended_list a,coll_suspended_cmd_log b
where a.suspended_seq=b.seq
and a.suspended_type=12
and b.crm_complete_code='0'
and a.closed_date is null
group by a.account_no,b.crm_complete_date
having to_char(add_months(max(b.crm_complete_date),3),'yyyymm')<to_char(sysdate,'yyyymm');
begin
select coll_program_control_log_seq.nextval into v_control_seq from dual;
insert into coll_program_control_log
(run_seq,
program_name,
run_start_time,
status)
values (v_control_seq,
'COLL_STOP3_ACCOUNTS_PROC',
sysdate,
0);

execute immediate 'truncate table bl_stopoverlimit_req';
delete from bl_stopoverlimit_req@spt11;
commit;

v_total_cnt:=0;
if get_stop_cur%isopen then
close get_stop_cur;
end if;
open get_stop_cur;
loop
fetch get_stop_cur into v_account_no,v_crm_complete_date;
exit when get_stop_cur%notfound;

select count(*) into v_cnt
from bl_fee_summary_local@spt11
where dbd_detail_seq in (select detail_seq
from bl_device_business_detail@spt11
where are_req_id=v_account_no
and business_close_date is null
and bty_business_type_id=1)
and to_char(fee_generate_date,'yyyymm')=to_char(sysdate,'yyyymm')
and amount_due>0;
if v_cnt>0 then
v_flag:=0; -- in use
else
v_flag:=1;-- not in use
end if;
insert into bl_stopoverlimit_req (req_id,flag,stop_date)
values (v_account_no,v_flag,v_crm_complete_date);

v_total_cnt:=v_total_cnt+1;
end loop;
close get_stop_cur;

update coll_program_control_log
set run_end_time = sysdate,
run_counts = v_total_cnt,
status = 1
where run_seq = v_control_seq;
commit;
insert into bl_stopoverlimit_req@spt11 select * from bl_stopoverlimit_req;
commit;
exception when others then
v_msg := sqlcode;
v_err := sqlerrm;
update coll_program_control_log
set run_end_time = sysdate,
run_counts = v_total_cnt,
status = v_msg,
err_desc = v_err
where run_seq = v_control_seq;
commit;
end;
...全文
118 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Coin_Guan 2010-04-22
  • 打赏
  • 举报
回复
要是能理解,那就是神仙了。
palosky 2010-04-20
  • 打赏
  • 举报
回复
这个东西没有业务背景,没有表之间的关系 叫人如何理解啊?

我感到费解……
wx358165717 2010-04-20
  • 打赏
  • 举报
回复
大家继续看啦 PSQL和TSQL有什么差别呢?
wx358165717 2010-04-20
  • 打赏
  • 举报
回复
SQL的应该是VIEW啊
存储过程是PROC啊
--小F-- 2010-04-20
  • 打赏
  • 举报
回复
好长 ..
htl258_Tony 2010-04-20
  • 打赏
  • 举报
回复
应该是oracle的存储过程
东那个升 2010-04-20
  • 打赏
  • 举报
回复
去oracle版块问吧。
you_tube 2010-04-20
  • 打赏
  • 举报
回复
procedure是视图?明明是存储过程哇
喜-喜 2010-04-20
  • 打赏
  • 举报
回复
试图吗?不想啊!存储过程吧!不过里面确实有看不明白的...

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧