我从桌子FOO和BAR中选择.我想锁定正在返回的FOO的记录,但我不想锁定BAR的记录.
cursor c_foobar is select foo.*,bar.* from foo,bar where foo.id = bar.foo_id for update of <what should I put here?>
好像我需要指定单独的列,但我希望锁定整个foo记录.例如我希望我可以这样做:
cursor c_foobar is select foo.*,bar where foo.id = bar.foo_id for update of foo
我是否必须在更新部分中枚举foo的每一列以便将它们全部锁定?或者我可以随意选择foo中的任何列,即使那些不是它的主键,它会锁定整个记录吗?
解决方法
从
the 10G PL/SQL documentation开始:
When querying multiple tables,you can
use the FOR UPDATE clause to confine
row locking to particular tables. Rows
in a table are locked only if the FOR
UPDATE OF clause refers to a column
in that table. For example,the
following query locks rows in the
employees table but not in the
departments table:
DECLARE CURSOR c1 IS SELECT last_name,department_name FROM employees,departments WHERE employees.department_id = departments.department_id AND job_id = 'SA_MAN' FOR UPDATE OF salary;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。