存程
--生票 @CpNoDate:票日期(8位) @JmpNo:要跳的票(流水) @CpNo:出(流水)
create procedure prc_GetCpNo (@CpNoDate char(8),@JmpNo int,@CpNo int output) with ENCRYPTION
as
declare @d33no char(12),@tmpI int
set nocount on
declare Cp_cursor cursor for Select distinct D33NO from Dt3_3 Where D33DT=@CpNoDate order by D33NO for read only
open Cp_cursor
fetch next from Cp_cursor into @d33no
if @@fetch_status=-1
begin
set @CpNo=0
if @JmpNo=@CpNo set @CpNo=@CpNo
end
else
begin
set @tmpi=0
while @tmpi <=1
begin
if right(@d33no,4) <> '0000 ' and @tmpi=0
set @cpno=0
else
begin
if @cpno is null
begin
set @cpno=convert(int,right(@d33no,4))
fetch next from Cp_cursor into @d33no
end
while @@fetch_status=0
begin
if convert(int,right(@d33no,4))-@cpno> 1 if @JmpNo <> @cpno+1 break
set @cpno=convert(int,right(@d33no,4))
fetch next from Cp_cursor into @d33no
end
set @cpno=@cpno+1
end
if @jmpno <> @cpno
set @tmpi=1
else
if @@fetch_status=-1
begin
set @cpno=@cpno+1
set @tmpi=1
end
set @tmpi=@tmpi+1
end--while @tmpi束
end
close Cp_cursor
deallocate Cp_cursor
set nocount off
此程在何就在已查到的d33no上加1?何是就返回原的d33no?
[解决办法]
他的返回值是@CpNo,你看看@CpNo量的值程。
另外,感了,生成流水不至於要的的。