【SQL开源代码栏目提醒】:网学会员为广大网友收集整理了,InGoodsList.sql,希望对大家有所帮助!
use BuyGoods
go
if object_id('dbo.InGoodsList') is not null
drop procedure dbo.InGoodsList
go
create procedure dbo.InGoodsList
@code char(2)=null,
@ckyear int=null,
@item int=null,
@condition varchar(30)=null
as
if(@code='A')
begin
select * From InGoods where ckyear=@ckyear order by item
return
end
if(@code='A0')
begin
select * From InGoods where ckyear=@ckyear and status='NG' order by item
return
end
if(@code='A1')
begin
select * From InGoods where ckyear=@ckyear and status='OK' order by item
return
end
if(@code='C')
begin
select * From InGoods where customer=@condition and ckyear=@ckyear order by item
return
end
if(@code='C0')
begin
select * From InGoods where customer=@condition and ckyear=@ckyear and status='NG' order by item
return
end
if(@code='C1')
begin
select * From InGoods where customer=@condition and ckyear=@ckyear and status='OK' order by item
return
end
if(@code='V')
begin
select * from InGoods where vendor= @condition and ckyear=@ckyear order by item
return
end
if(@code='V0')
begin
select * from InGoods where vendor= @condition and ckyear=@ckyear and status='NG' order by item
return
end
if(@code='V1')
begin
select * from InGoods where vendor= @condition and ckyear=@ckyear and status='OK' order by item
return
end
if(@code='M')
begin
select * from InGoods where model like @condition+'%' and ckyear=@ckyear order by item
return
end
if(@code='M0')
begin
select * from InGoods where model like @condition+'%' and ckyear=@ckyear and status='NG' order by item
return
end
if(@code='M1')
begin
select * from InGoods where model like @condition+'%' and ckyear=@ckyear AND status='OK' order by item
return
end
if(@code='D')
begin
select * from InGoods where description like @condition+'%' and ckyear=@ckyear order by item
return
end
if(@code='D0')
begin
select * from InGoods where description like @condition+'%' and ckyear=@ckyear and status='NG' order by item
return
end
if(@code='D1')
begin
select * from InGoods where description like @condition+'%' and ckyear=@ckyear and status='OK' order by item
return
end
if(@code='R')
begin
select * from InGoods where rpno=@condition and ckyear=@ckyear order by item
return
end
if(@code='R0')
begin
select * from InGoods where rpno=@condition and ckyear=@ckyear and status='NG' order by item
return
end
if(@code='R1')
begin
select * from InGoods where rpno=@condition and ckyear=@ckyear and status='OK' order by item
return
end
if(@code='X')
begin
select * from InGoods where insp_date like @condition+'%' order by item
return
end
if(@code='X0')
begin
select * from InGoods where insp_date like @condition+'%' and status='NG' order by item
return
end
if(@code='X1')
begin
select * from InGoods where insp_date like @condition+'%' and status='OK' order by item
return
end
if(@code='S')
begin
select * from InGoods where source= @condition and ckyear=@ckyear order by item
return
end
if(@code='S0')
begin
select * from InGoods where source= @condition and ckyear=@ckyear and status='NG' order by item
return
end
if(@code='S1')
begin
select * from InGoods where source= @condition and ckyear=@ckyear and status='OK' order by item
return
end
go