首页 > 代码库 > sybase创建存储过程

sybase创建存储过程

create procedure P_mng_prize                                                                
   @ResultCode     char(1)  out,                                                                     
   @ResultMsg      char(50) out,                                                                     
                                                                                                     
   @action_id      varchar(30),                                                                      
   @operator_id    char(6),                                                                          
                                                                                                     
     @prize_id      char(4)      ,
     @store_id      char(15)                                                         
as                                                                                                   
declare @xcount int                                                                                  
declare @logmsg varchar(250)           
declare @tmpPrize_id char(4)            
declare @today char(8)       
declare @tmpStatus char(1)                           
begin                                                                                                
                                                                                                                                                                                                 
    select @ResultCode = ‘1‘                                                                         
    select @ResultMsg  = "不支持的操作:" + @action_id                                                
    select @today = convert(char(8),getdate(),112)                                                                    
                                                                                                     
    if( @action_id = ‘add_commit‘)                                                                   
    begin                                                                                                       
        insert into prize__store
        (prize_id,store_id)
        values( @prize_id, @store_id)
                                                                                                     
        if (@@sqlstatus = 1)                                                                         
        begin                                                                                        
            select @ResultCode = ‘1‘                                                                 
            select @ResultMsg  = "增加失败!"                                                         
        end                                                                                          
        else                                                                                         
        begin                                                                                         
            select @ResultCode = ‘0‘                                                                 
            select @ResultMsg  = "增加成功!"                                                         
        end                                                                                          
    end                                                                                              
                                                                                                     
    if( @action_id = ‘update_commit‘)                                                                
    begin                                                      
        select @ResultCode = ‘1‘                                                                   
        select @ResultMsg  = "不允许删除!"                                                          
    end                                                                                              
                                                                                                     
    if( @action_id = ‘delete‘)                                                                       
    begin                           
          delete prize_store
          where  prize_id = @prize_id
                                                                            
        if (@@sqlstatus = 1)                                                                         
        begin                                                                                        
            select @ResultCode = ‘1‘                                                                 
            select @ResultMsg  = "增加失败!"                                                         
        end                                                                                          
        else                                                                                         
        begin                                                                                         
            select @ResultCode = ‘0‘                                                                 
            select @ResultMsg  = "增加成功!"                                                         
        end                                                                               
    end                                                                                                               
                                                                                                     
    select @logmsg = "日志:"+@action_id+" id: "+@prize_id +" rst:"+ @ResultMsg                   
                                                                                                     
    insert into SYSROCORDLOG(OPER,OPTYPE,OPTIME,DISCRIBE) values(@operator_id,‘01‘,getdate(),@logmsg)      
                                                                                                     
    return 0                                                                                         
end
go

sybase创建存储过程