When I try to modify the interactive grid column it gives ORA-02014 error.
In back-end i have used sql query with union in it and also used join to join 3 tables.
I tried in the last couple of days and I expect someone might have the solution.
When I try to modify the interactive grid column it gives ORA-02014 error.
In back-end i have used sql query with union in it and also used join to join 3 tables.
I tried in the last couple of days and I expect someone might have the solution.
There error pretty much says it all. The database engine cannot determine how to update the data from the select query. When the interactive grid is rendered, it will try to do a SELECT * FROM (<the IG query>) FOR UPDATE
. In your case, this statement is erroring out when you add the union. This is what happening under the hood:
query without union works fine:
select * from (
select * from emp where ename = 'KING'
) for update;
query with union works cannot be selected for update:
select * from (
select * from emp where ename = 'KING'
union all
select * from emp where ename = 'BLAKE'
) for update;
Error at line 1/15: ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
Any of the solutions @Littlefoot mentions will could work.
There might be other options than the one I'm going to suggest - such as
rewriting query so that you don't join tables, but fetch lookup values via functions and then set those columns to read only so that updates don't affect them, or
you could (in Apex) create your own process, such as this one (see "Help" for more sample code), with these settings:
I prefer creating a view and instead-of trigger which handles updates.
Here's an example; see if it helps.
View that joins some tables and contains
union
(that's what you described):This is one row:
What happens if we try to update it? Fails (not with your error, though, but - it fails):
Instead-of trigger:
Re-run the same
update
statement:Right; now it works and updates value - not in a view (it just reflects that change), but in underlying table: