ora-02014

How to solve ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY

房东的猫 提交于 2019-12-19 17:31:12
问题 I want to lock a group of records using the following query: select * from (select * from event_table where status = 'S' order by creation_data asc ) where rownum <=10 for update; event_table is not a view. It is a regular table: create table event_table ( id number, creation_date date, status number, info clob ); The primary key is the field id. Can I use rownum with select for update at all? Is there another solution where using select for update but also selecting just a group of rows and

How can I use “FOR UPDATE” with a JOIN on Oracle?

做~自己de王妃 提交于 2019-12-08 08:22:43
问题 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 wonder how I can use this statement together with the keyword FOR UPDATE . If I simply append it to the query, Oracle will tell me: ORA-02014: cannot select FOR UPDATE from view Do I have to modify the query or is there a trick to do this with Oracle? With MySql the statement works fine. 回答1: try:

How can I use “FOR UPDATE” with a JOIN on Oracle?

回眸只為那壹抹淺笑 提交于 2019-12-08 05:16:20
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 wonder how I can use this statement together with the keyword FOR UPDATE . If I simply append it to the query, Oracle will tell me: ORA-02014: cannot select FOR UPDATE from view Do I have to modify the query or is there a trick to do this with Oracle? With MySql the statement works fine. try: select ..... from <choose your table> where id in (<your join query here>) for UPDATE; EDIT : that might

How to solve ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY

为君一笑 提交于 2019-12-01 16:55:50
I want to lock a group of records using the following query: select * from (select * from event_table where status = 'S' order by creation_data asc ) where rownum <=10 for update; event_table is not a view. It is a regular table: create table event_table ( id number, creation_date date, status number, info clob ); The primary key is the field id. Can I use rownum with select for update at all? Is there another solution where using select for update but also selecting just a group of rows and not all the results from the select? For example, I have a task that runs every X internal and needs to

How to work around ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc

 ̄綄美尐妖づ 提交于 2019-12-01 08:49:06
I want to lock one record in a table. The record is specified as "the next that has ID greater than..." CREATE TABLE test (id number); SELECT id FROM (SELECT id FROM test WHERE id > 10 ORDER BY id) WHERE ROWNUM = 1 FOR UPDATE; This seems intuitive and easy. But it is not. Any ideas? P.S. I do need the existing query to remain the same because it is a cursor and there are several places that use this cursor's %rowtype. I think you're going to need something like: SELECT id FROM test WHERE id = (SELECT MIN(id) FROM test WHERE id > 10) FOR UPDATE; 来源: https://stackoverflow.com/questions/3166615

How to work around ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc

北战南征 提交于 2019-12-01 06:40:46
问题 I want to lock one record in a table. The record is specified as "the next that has ID greater than..." CREATE TABLE test (id number); SELECT id FROM (SELECT id FROM test WHERE id > 10 ORDER BY id) WHERE ROWNUM = 1 FOR UPDATE; This seems intuitive and easy. But it is not. Any ideas? P.S. I do need the existing query to remain the same because it is a cursor and there are several places that use this cursor's %rowtype. 回答1: I think you're going to need something like: SELECT id FROM test WHERE