发布网友 发布时间:2022-04-08 10:39
共3个回答
懂视网 时间:2022-04-08 15:00
alter PROCEDURE [dbo].[sp_gongzi] @gongzi_yf varchar(7) as
DECLARE @input_id varchar(20)
DECLARE @sk_sum decimal(18, 3)
DECLARE @sk_sum_yk decimal(18, 3)
BEGIN
DECLARE cur_input CURSOR FOR
select docno from tc_tab1 where yf = @gongzi_yf
OPEN cur_input
FETCH cur_input INTO @input_id
WHILE @@FETCH_STATUS = 0
BEGIN
set @sk_sum = 0
set @sk_sum_yk = 0
select @sk_sum = sum(je * case when (hl2 is null) then hl else hl2 end )
from sk_dan where docno =@input_id;
select @sk_sum_yk = sum(je * case when (hl2 is null) then hl else hl2 end )
from sk_dan_yk where docno =@input_id;
set @sk_sum = case when (@sk_sum is null) then 0 else @sk_sum end;
set @sk_sum_yk = case when (@sk_sum_yk is null) then 0 else @sk_sum_yk end;
update tc_tab1 set dke2 = @sk_sum + @sk_sum_yk
where docno = @input_id;
FETCH cur_input INTO @input_id
END
CLOSE cur_input
DEALLOCATE cur_input
--*/
END
循环处理--sqlserver
标签:
热心网友 时间:2022-04-08 12:08
游标循环热心网友 时间:2022-04-08 13:26
Do While Not rs.EOF