????????α??ü?
???????????? ???????[ 2012/8/2 10:39:04 ] ????????
??????????
Declare company_crsr cursor
For select name??salary from company where salary>2000
For update of name??salary
????????????????????????company_crsr???α?
??????2?????α?
????open???????
????open ?α???
???????????α??????????????fetch??update??delete?????????????С????????α?????????????α????????????????????fetch??????????С?
??????3??????α?????
??????????????????α??????fetch??????α??????л???????С?
????Fetch???????
????Fetch [[Next | Prior | First | Last | Absolute{n|@nvar} |Relative {n|@nvar}]
????From] ?α??? [into ?????б?]
?????????????
????Next???????????е???е?????У??????????????ζ????????????????????????
????Prior???????????е???е?????У??????????????ζ????????е??????????????????????α?λ???????????С?
????First???????α????У?Last???????α??е????У?
????Absolute{n|@nvar}????? n ?? @nvar ?????????????α???????? n ?в?????????б???μ????С???? n ?? @nvar ????????????α?β????? n ?в?????????б???μ????С???? n ?? @nvar ? 0????????з????n ?????????????? @nvar ????? smallint??tinyint ?? int??
????RELATIVE {n | @nvar}????? n ?? @nvar ???????????????????? n ?в?????????б???μ????С???? n ?? @nvar ???????????????????? n ?в?????????б???μ????С???? n ?? @nvar ? 0?????????С???????α???????????????? FETCH RELATIVE ?? n ?? @nvar ?????????? 0????????з????n ?????????????? @nvar ????? smallint??tinyint ?? int??
??????????
Fetch next
company_crsr into @name??@salary
????SQL Server????ζ??????????????????@@sql_status?????????±??????????@@sql_status????????塣
????????壺
????0——Fetch?????
????1——Fetch??????????
????2——???????и????????????λ??λ??????????У??????????α??????Fetch??????
???????α??????μ??????update??delete????????o?????С?
????????α???е??????
????Delete [from] ????
????where current of ?α???
??????????delete from authors where current of authors_crsr
???????α??????к?SQL Server???α??????????е????????
?????????α???е??????
????update ????
????set column_name1={expression1|NULL|(select_statement)}
????[??column_name2={expression2|NULL|(select_statement)}
????[……]
????where current of ?α???
??????????
????update company
????set name=”????”??salary=”5000”
????where current of company_crsr
??????4??????α?
??????????????α????????????close???????????
????close ?α???
????????α?????????壬????open??δ???????????α????????deallocate???????deallocater???????
????deallocater cursor ?α???
????deallocater?????SQL Server???Declare????????????棬????????????????????????Open??????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11