Created
June 8, 2012 00:45
-
-
Save ichiroku11/2892705 to your computer and use it in GitHub Desktop.
カーソルの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- cursorを宣言 | |
declare cur cursor | |
for | |
select ... | |
-- cursorを開く | |
open cur; | |
-- 1行ごとにデータを取り出す | |
fetch next from cur into @v1, @v2, ...; | |
-- ループ | |
while @@fetch_status = 0 -- fetchは正常に実行された | |
begin | |
-- 1行ごとにデータを取り出す | |
fetch next from cur into @v1, @v2, ...; | |
end | |
-- カーソルを閉じる | |
close cur; | |
-- カーソルに割り当てられたリソースを解放 | |
deallocate cur; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment