生活随笔
收集整理的這篇文章主要介紹了
MS SQL Server2005存储过程、游标、游标嵌套综合例子
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
MS SQL Server2005存儲過程、游標、游標嵌套綜合例子:
放在這里備忘》》》
Java代碼 ?
create?proc?decisionPathRefSchemes??as??begin??????DECLARE?@pathId?varchar(64)??????DECLARE?@schemeId?varchar(64)??????DECLARE?@flag?integer??????DECLARE?@seq?integer??????DECLARE?mycursor?cursor????????????for?select?id?from?imps_pd_decision_path?where?surfaceType?=?'瀝青路面'?and?roadGrade?=?'高速、一級、二級'??????DECLARE?mycursor2?cursor????????????for?select?id?from?imps_pd_decision_scheme?????????????????set?@seq?=?10000????????????open?mycursor???????fetch?next?from?mycursor?into?@pathId??????while?@@fetch_status=0??????begin???????????set?@flag?=?0??????????select?@flag=1?from?imps_pd_path_ref_scheme?where?pathId=@pathId??????????print?@pathId??????????print?@flag??????????if?@flag?=?0???????????begin????????????????????????????open?mycursor2??????????????fetch?next?from?mycursor2?into?@schemeId??????????????while?@@fetch_status=0??????????????begin??????????????????insert?into?imps_pd_path_ref_scheme?(id,pathId,schemeId)?values?(convert(varchar(64),?@seq),@pathId,@schemeId)??????????????????set?@seq?=?@seq?+?1???????????????????fetch?next?from?mycursor2?into?@schemeId??????????????end??????????????close?mycursor2????????????????????????????????????????????????????????????????????????end??????????fetch?next?from?mycursor?into?@pathId??????end????????????deallocate?mycursor2??????close?mycursor????????????deallocate?mycursor??end??????--exec?decisionPathRefSchemes??????--drop?proc?decisionPathRefSchemes
總結
以上是生活随笔為你收集整理的MS SQL Server2005存储过程、游标、游标嵌套综合例子的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。