增加存储过程参数,确保调用老接口程序不出错

该博客为转载内容,转载自https://www.cnblogs.com/Elong/archive/2005/09/05/230465.html ,涉及开发工具领域。
存储过程如果新增加参数.
让该参数使用默认值,
存储过程中根据默认值分支.以确保以前使用老的存储过程不出错

老存储过程
None.gifcreate procedure yaf_topic_save(   
None.gif
@PhotoFilmName varchar(50)=' ',  
None.gif
@PhotoCamera varchar(50)=' '  
None.gif
as  
None.gif
begin  
None.gif  
declare @TopicID bigint  
None.gif 
declare @MessageID bigint  
None.gif    
None.gif
declare @Posted datetime
None.gif 
set @Posted = getdate()  
None.gif 
if @ActionDate is null set @ActionDate = getdate()  
None.gif   
None.gif 
insert into yaf_Topic(ForumID,Topic,UserID,Posted,Views,Priority,IsLocked,PollID,NumPosts,TopicMovedID,PhotoTypeID,PhotoFilmName,PhotoCamera,ActionDate)  
None.gif 
values(@ForumID,@Subject,@UserID,@Posted,0,@Priority,0,@PollID,0,@TopicMovedID,@PhotoTypeID,@PhotoFilmName,@PhotoCamera,@ActionDate)  
None.gif
None.gif
end  
新存储过程
None.gif
None.gif
create procedure yaf_topic_save(   
None.gif
@PhotoFilmName varchar(50)=' ',  
None.gif
@PhotoCamera varchar(50)=' '
None.gif
@Posted datetime= null
None.gif  
None.gif
as  
None.gif
begin  
None.gif  
declare @TopicID bigint  
None.gif 
declare @MessageID bigint  
None.gif
None.gif
if @Posted is null set @Posted = getdate()  
None.gif 
if @ActionDate is null set @ActionDate = getdate()  
None.gif   
None.gif 
insert into yaf_Topic(ForumID,Topic,UserID,Posted,Views,Priority,IsLocked,PollID,NumPosts,TopicMovedID,PhotoTypeID,PhotoFilmName,PhotoCamera,ActionDate)  
None.gif 
values(@ForumID,@Subject,@UserID,@Posted,0,@Priority,0,@PollID,0,@TopicMovedID,@PhotoTypeID,@PhotoFilmName,@PhotoCamera,@ActionDate)  
None.gif
None.gif
end  
None.gif
None.gif

转载于:https://www.cnblogs.com/Elong/archive/2005/09/05/230465.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值