drop  procedure p_get_oclist_with_itemnumber 

 go 


 /* 定义输入参数 orderno , 输出参数 @oc_list*/ 

 create procedure p_get_oclist_with_itemnumber 

 (@orderno varchar(30),@oc_list varchar(255) output) 

 as 

 declare  @oc varchar(30) 

 declare  @oclist varchar(30) 

 begin 

         declare cursor1 cursor for select distinct oc_number from p_package_oa where order_no=@orderno 

         open cursor1 

         fetch cursor1 into @oc 

         while @@sqlstatus = 0 

         begin 

              select @oclist=@oclist+@oc 

              fetch cursor1 into @oc 

         end 

         select @oc_list=@oclist 

         close cursor1 

 end 

 go 



 /* 定义输入输出参数 */ 

 declare @findword char(255) -- define output param ofindword 

 declare @no char(30) 

 select  @no='JH 0902008' 


 /* 在 SQL 后台运行此存储过程测试 */ 

 execute p_get_oclist_with_itemnumber  @no,@findword output 

 go 

   

 /* 运行结果 :E0800120 E0800130*/