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

mac2022-06-30  17

存储过程如果新增加参数. 让该参数使用默认值, 存储过程中根据默认值分支.以确保以前使用老的存储过程不出错 老存储过程 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    新存储过程 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   

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

相关资源:Java调用存储过程的2种方法
最新回复(0)