亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請教SQL關于游標的問題

請教SQL關于游標的問題

汪汪一只貓 2018-12-06 23:04:53
存儲過程有個參數,根據這個參數來分別寫的游標查詢語句,但是處理這個游標是同一個代碼,好像不能同時定義兩次,我又不想把后續的處理代碼寫兩次,有什么辦法嗎? declare @tempid int,@lasttime datetime,@sql nvarchar(1000) set @tempid=0; BEGIN SET NOCOUNT ON; if @para1='oneself' begin declare bzrid cursor for select id from erpzjbzrlist as a end else if @para1='all' begin declare bzrid cursor for select id from erpzjbzrlist as a where (select max(endtime) from erpzjphasetime where bianhao=a.id group by bianhao) >=getdate(); end else begin return -1 end open bzrid fetch next from bzrid into @tempid while (@@fetch_status=0) begin select @lasttime =max(endtime) from erpzjphasetime where bianhao=(select id from erpzjbzrlist as a where (select max(endtime) from erpzjphasetime where bianhao=a.id group by bianhao) >=getdate() and id<@tempid) group by bianhao if(@lasttime<>null) begin select @lasttime=dateadd(day,1,@lasttime); exec ERP_p_adjustProjectTime @tempid,@lasttime; end fetch next from bzrid into @tempid end
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 606 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號