delimiter || 
  
 
  

    CREATE procedure next 
  
 
  

    (in in_id            INT, 
  
 
  

     in in_table_code      VARCHAR(255), 
  
 
  

     in in_site_code     VARCHAR(20), 
  
 
  

     in in_goods_code    VARCHAR(40), 
  
 
  

     out out_min_id     INT, 
  
 
  

     out out_price DOUBLE, 
  
 
  

     out out_comment_total INT 
   
  

    ) 
  
 
  

    begin 
  
 
  

    select  min(id) from price_history 
  
 
  

    where id>in_id and table_code=in_table_code and site_code=in_site_code 
  
 
  

        and goods_code=in_goods_code into out_min_id; 
  
 
   
  

    select comment_total from price_history where id=out_min_id into out_comment_total; 
   
  

    end|| 
  
 
  

    delimiter ; 
  
 
   
   
   
  

    call next(1,'01','360BUY','595936',@out_min_id,@p,@c); 
  
 
  

    select @out_min_id,@p,@c;