码迷,mamicode.com
首页 > 数据库 > 详细

sybase创建存储过程

时间:2017-04-03 22:17:19      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:add   var   bsp   insert   删除   mit   ptime   tco   rdl   

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创建存储过程

标签:add   var   bsp   insert   删除   mit   ptime   tco   rdl   

原文地址:http://www.cnblogs.com/yangxuming/p/6663650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!