Oracle locking with SELECT…FOR UPDATE OF

前端 未结 1 595
挽巷
挽巷 2020-12-31 17:52

I\'m selecting from tables FOO and BAR. I\'d like to lock the records of FOO which are being returned, but I don\'t want the records of BAR to be locked.

cu         


        
相关标签:
1条回答
  • 2020-12-31 18:22

    From 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;
    
    0 讨论(0)
提交回复
热议问题