各种功能 存储过程 (二)

/*根据id号获取新闻数据*/
create proc tgr_GetNewsInfoByNid @KeyId int
as
begin
  select * from RTO_TbNews where Nid=@KeyID
end


/*增加新闻点评信息*/
create proc tgr_AddCommentInfo @StrA nvarchar(500) ,@StrB nvarchar(500), @IntA int
as
begin
   insert into RTO_Commen values(@Stra,@StrB,@IntA,getdate())
end

/*添加新闻数据*/
create proc tgr_AddNewsDataInfo @StrA nvarchar(500),@StrB nvarchar(500),@StrC ntext,@IntA int,@IntB int,
@IntC int,@StrD nvarchar(500),@StrE nvarchar(500),@StrF nvarchar(500)
as
begin
   declare @Flags int
   select @Flags=Nid from RTO_TbNews where Title=@StrA
   if @Flags is null
       begin
             insert into RTO_TbNews(Title,Author,N_Content,ClickNum,Ntype,Bid,Sid,Position,ImgUrl,HtmlFileName,Bind,AddDate) 
values(@StrA,@StrB,@StrC,0,@IntA,@IntB,@IntC,@StrD,@strE,@strF,0,getdate())
             select @@identity as returnflag
     end
else
  begin
   select 0 as returnflag
  end
end

/*删除数据通用过程*/
create proc tgr_DelDataByID @KeyID int,@KeyS nvarchar(50)
as
begin
 --删除大类信息--
    if @KeyS='Bclass'
     begin
          set xact_abort on
          begin transaction
           delete from RTO_Bclass where Bid=@KeyID
          commit transaction
     end
 --删除小类信息--
else if @KeyS='Sclass'
    begin
      set xact_abort on
      begin transaction
          delete from RTO_Sclass where Sid =@KeyID
      commit transaction
    end
 --删除标签信息--
else if @KeyS='Flags'
 begin 
     set xact_abort on
     begin transaction
        delete from RTO_SysFlg where Pid=@KeyID
     commit transaction 
     end
--删除新闻信息--
else if @keys='News'
   begin
       set xact_abort on
     begin transaction 
           delete from RTO_TbNews where Nid=@KeyID
          commit transaction
     end
--删除评论--
else if @KeyS='Comment'
    begin
            set xact_abort on
            begin transaction
             delete from RTO_Commen where Did=@KeyID
           commit transaction
 end
end

/*根据id号更新新闻信息*/
create proc tgr_UpdNewsDataInfo @StrA nvarchar(500),@StrB nvarchar(500),
      @StrC ntext,@IntA int,@IntB int,@IntC int,@IntD int,@StrD nvarchar(500),@StrE nvarchar(500)
as
begin
  begin
          set xact_abort on
      begin transaction
     update RTO_TbNews set Title=@StrA, Author=@StrB,N_Content=@StrC,Ntype=@IntA,
           Bid=@IntB,Sid=@IntC,Position=@StrD,ImgUrl=@StrE where Nid=@IntD
      commit transaction
end
end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值