How can I use "FOR UPDATE" with JOIN on Oracle?

The answer to another SO question was to use this SQL query:

SELECT o.Id, o.attrib1, o.attrib2 
  FROM table1 o
  JOIN (SELECT DISTINCT Id 
          FROM table1, table2, table3 
         WHERE ...) T1 ON o.id = T1.Id

Now I am wondering how I can use this operator along with the keyword FOR UPDATE. If I just add it to the query, Oracle will tell me:

ORA-02014: cannot select FOR UPDATE from view

Do I need to modify a query or is there a trick to do this with Oracle? With MySql, the expression works fine.

+1
source share
2 answers

to try:

select ..... 
from <choose your table>
where id in (<your join query here>) for UPDATE;

: , ( , IN), - , . , : ; , - DISTINCT. DISTINCT, , , , : http://www.dba-oracle.com/t_ora_02014_cannot_select_for_update.htm

+4

, . ... FOR UPDATE OF o.attrib1 , , , , ; , . ( , - - , , FOR UPDATE OF).

, MySQL, .

0

Source: https://habr.com/ru/post/1740004/


All Articles