各種功能 存儲過程 (二)

/*根據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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章