WHERE CURRENT OF 有什么作用Select For Update有什么作用

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 11:55:03
WHERE CURRENT OF 有什么作用Select For Update有什么作用
xUOAWŠ MDn dۆcM3x?H0$ jc4Pjr_`zx7}{_i'ӦeQ,3[\gA#vGkԣDB (+e16D% EON!BݷͰ}%Z:~k,v_n?]@ױhioo?꬏bm v%فO/BV9K-)sDĴq9hQo+$HxJi6Gk5Zq1l/ۍrEiU ߗ՟ܰX973el# .B!j.w{:eI*I0_r ]WXds߁[KK xF g3*agf1+\G}z|'țٔޤI݇8\hxj!U1`3Zݣ_`R9ApQ y<{hF7⿑'[6~7P

WHERE CURRENT OF 有什么作用Select For Update有什么作用
WHERE CURRENT OF 有什么作用
Select For Update有什么作用

WHERE CURRENT OF 有什么作用Select For Update有什么作用
如果你想删除或者更新被Select For Update引用的记录,你可以使用Where Current Of语句.
UPDATE table_name
SET set_clause
WHERE CURRENT OF cursor_name;
OR
DELETE FROM table_name
WHERE CURRENT OF cursor_name;
Where Current Of语句允许你更新或者是删除最后由cursor取的记录.
下面一个使用Where Current Of更新记录的例子:
CREATE OR REPLACE Function FindCourse
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
CURSOR c1
IS
SELECT course_number,instructor
from courses_tbl
where course_name = name_in
FOR UPDATE of instructor;
BEGIN
open c1;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
else
UPDATE courses_tbl
SET instructor = 'SMITH'
WHERE CURRENT OF c1;
COMMIT;
end if;
close c1;
RETURN cnumber;
END;
Deleting using the WHERE CURRENT OF Statement
Here is an example where we are deleting records using the Where Current Of Statement:
译:下面一个使用Where Current Of删除记录的例子:
CREATE OR REPLACE Function FindCourse
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
CURSOR c1
IS
SELECT course_number,instructor
from courses_tbl
where course_name = name_in
FOR UPDATE of instructor;
BEGIN
open c1;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
else
DELETE FROM courses_tbl
WHERE CURRENT OF c1;
COMMIT;
end if;
close c1;
RETURN cnumber;
END;