增加存储过程参数,确保调用老接口程序不出错
存储过程如果新增加参数.
让该参数使用默认值,
存储过程中根据默认值分支.以确保以前使用老的存储过程不出错
老存储过程
新存储过程
create procedure yaf_topic_save(
@PhotoFilmName varchar(50)=' ',
@PhotoCamera varchar(50)=' ',
@Posted datetime= null
) as
begin
declare @TopicID bigint
declare @MessageID bigint
if @Posted is null set @Posted = getdate()
if @ActionDate is null set @ActionDate = getdate()
insert into yaf_Topic(ForumID,Topic,UserID,Posted,Views,Priority,IsLocked,PollID,NumPosts,TopicMovedID,PhotoTypeID,PhotoFilmName,PhotoCamera,ActionDate)
values(@ForumID,@Subject,@UserID,@Posted,0,@Priority,0,@PollID,0,@TopicMovedID,@PhotoTypeID,@PhotoFilmName,@PhotoCamera,@ActionDate)
end
让该参数使用默认值,
存储过程中根据默认值分支.以确保以前使用老的存储过程不出错
老存储过程
create procedure yaf_topic_save(
@PhotoFilmName varchar(50)=' ',
@PhotoCamera varchar(50)=' '
) as
begin
declare @TopicID bigint
declare @MessageID bigint
declare @Posted datetime
set @Posted = getdate()
if @ActionDate is null set @ActionDate = getdate()
insert into yaf_Topic(ForumID,Topic,UserID,Posted,Views,Priority,IsLocked,PollID,NumPosts,TopicMovedID,PhotoTypeID,PhotoFilmName,PhotoCamera,ActionDate)
values(@ForumID,@Subject,@UserID,@Posted,0,@Priority,0,@PollID,0,@TopicMovedID,@PhotoTypeID,@PhotoFilmName,@PhotoCamera,@ActionDate)
end
@PhotoFilmName varchar(50)=' ',
@PhotoCamera varchar(50)=' '
) as
begin
declare @TopicID bigint
declare @MessageID bigint
declare @Posted datetime
set @Posted = getdate()
if @ActionDate is null set @ActionDate = getdate()
insert into yaf_Topic(ForumID,Topic,UserID,Posted,Views,Priority,IsLocked,PollID,NumPosts,TopicMovedID,PhotoTypeID,PhotoFilmName,PhotoCamera,ActionDate)
values(@ForumID,@Subject,@UserID,@Posted,0,@Priority,0,@PollID,0,@TopicMovedID,@PhotoTypeID,@PhotoFilmName,@PhotoCamera,@ActionDate)
end
create procedure yaf_topic_save(
@PhotoFilmName varchar(50)=' ',
@PhotoCamera varchar(50)=' ',
@Posted datetime= null
) as
begin
declare @TopicID bigint
declare @MessageID bigint
if @Posted is null set @Posted = getdate()
if @ActionDate is null set @ActionDate = getdate()
insert into yaf_Topic(ForumID,Topic,UserID,Posted,Views,Priority,IsLocked,PollID,NumPosts,TopicMovedID,PhotoTypeID,PhotoFilmName,PhotoCamera,ActionDate)
values(@ForumID,@Subject,@UserID,@Posted,0,@Priority,0,@PollID,0,@TopicMovedID,@PhotoTypeID,@PhotoFilmName,@PhotoCamera,@ActionDate)
end