标题:存储过程,请各位分析
只看楼主
jxawgya
Rank: 1
等 级:新手上路
帖 子:64
专家分:9
注 册:2010-1-5
结帖率:91.67%
已结贴  问题点数:20 回复次数:1 
存储过程,请各位分析
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



--自动缴款

ALTER PROCEDURE  [dbo].[sp_mzsf_pay_jk]
 AS

DECLARE @opecode varchar(6),@billid varchar(12),@y int,@aa varchar(8)

set @aa = cast(year(getdate()) as varchar(4) )+ right('00'+cast(month(getdate()) as varchar(2)),2) + right('00'+cast(day(getdate()) as varchar(2)),2)
set @y = 0

declare  cur scroll cursor
for
select OPERATOR_CODE from ci_invoice
WHERE pay_date is null
group by OPERATOR_CODE
open cur

set @y =@y + 1
set @billid = @aa + right('0000'+cast(@y as varchar(4)),4)

fetch first from cur into @opecode
while ( @@fetch_status<>-1)
begin
insert into ci_invoice_pay(bill_id,invoice_sum,price_subclass)
select @billid,sum(invoice_sum),PRICE_SUBCLASS
from ci_invoice
where OPERATOR_CODE =@opecode and pay_flag = '0'  and CANCEL_SIGN = '1'  and  pay_date is null
group by price_subclass


fetch next from cur into @opecode

end
close cur
deallocate cur

update ci_invoice set pay_flag = '1' , pay_date =getdate()
where pay_date is null and pay_flag = '0'

update ci_withdraw_info set pay_flag = '1' , pay_date =getdate()
where pay_date is null and pay_flag = '0'

以上存储过程请各们分析,
2011-06-04 08:38
panyanpan
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:82
专家分:647
注 册:2011-4-6
得分:20 
请问下 要具体如何分析,还有表结构,对应实现的功能是什么
2011-06-09 09:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-341863-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.514971 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved