use buygoods1
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