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

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


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;
...全文
238 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangsong145 2010-04-21
  • 打赏
  • 举报
回复
是个存储过程,貌似是从一个表取数据插入另外一个表,但是没有表结构和数据字典之类的,很难看出是写的什么意思啊
wx358165717 2010-04-21
  • 打赏
  • 举报
回复
存储过程嘛明显是
liukai_happy 2010-04-21
  • 打赏
  • 举报
回复
这时视图么 晕! 时存储过程啊!!!
Leshami 2010-04-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 tangren 的回复:]

没有数据结构,不好分析
注释写的是取停机三个月的帐号
[/Quote]

是存储过程,且使用过了游标来处理。
zsjkulong 2010-04-21
  • 打赏
  • 举报
回复
明显是过程,怎么看成视图的?
zhangwonderful 2010-04-21
  • 打赏
  • 举报
回复
明显是存储过程
iqlife 2010-04-21
  • 打赏
  • 举报
回复
procedure
视图?你同学也太牛了,难道想指鹿为马?
winter_sui 2010-04-21
  • 打赏
  • 举报
回复
苍天那。你就活生生的把代码贴出来了,还说是电信的。
这要是换成我们就费了,非被当成泄漏商业机密给毕了不可。
  • 打赏
  • 举报
回复
procedure=存储过程
Dave 2010-04-21
  • 打赏
  • 举报
回复


不明真相群众围观...
huanmie_09 2010-04-20
  • 打赏
  • 举报
回复
看上去比较简单的一个存储过程,这个要根据业务逻辑来分析它的用途了.
比如加上条件的口径之类.
tangren 2010-04-20
  • 打赏
  • 举报
回复
没有数据结构,不好分析
注释写的是取停机三个月的帐号
codearts 2010-04-20
  • 打赏
  • 举报
回复
create or replace procedure coll.coll_stop3_accounts_proc

从这句可以看出,是个存储过程。

你的这么长的一段代码,表结构啥的都没用。。。。。。不好说是啥意思。。。。。


存储过程中最好少用游标,数据应该使用集合的思想来处理

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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