title: How to resolve "cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc" error in Oracle Apex?
body: <p>I have a events page in my Oracle Apex application with data source set to a view created by joining multiple tables. So when a user tries to update an event it fails because the system tries to make update to the view not the actual table. That's why I created a trigger function that updates the actual table instead of the view. But i am still getting an error.</p>
  
  <p><a href="https://i.stack.imgur.com/2WO8N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2WO8N.png" alt="enter image description here"></a></p>
  
  <p>This is the script for the trigger:</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER t_update_event
  INSTEAD OF UPDATE ON v_event
  BEGIN 
      UPDATE Event
      SET start_date = :new.start_date,
          end_date = :new.end_date,
          start_time = :new.start_time,
          end_time = :new.end_time,
          description = :new.description
      WHERE event_id = :old.event_id;
  END;
  /
  ALTER TRIGGER t_update_event ENABLE
  /
  </code></pre>
  
  <p>How can I solve this? Is there something wrong with my code?</p>
  
  <p>If this is of any help, following is the script for the view.</p>
  
  <pre><code>CREATE OR REPLACE FORCE VIEW "V_EVENT" ("EVENT_ID", "EVENT_NAME", "START_DATE", "END_DATE", "START_TIME", "END_TIME", "DESCRIPTION", "FROM_COLLEGE", "FROM_COMMUNITY", "CLUB_NAME") AS 
    SELECT event."EVENT_ID"
    ,event."EVENT_NAME"
    ,event."START_DATE"
    ,event."END_DATE"
    ,event."START_TIME"
    ,event."END_TIME"
    ,event."DESCRIPTION"
    ,CASE WHEN event."FROM_COLLEGE" = 0 THEN 'No'
    WHEN event."FROM_COLLEGE" = 1 THEN 'Yes'
    END AS "From College"
    ,CASE WHEN event."FROM_COMMUNITY" = 0 THEN 'No'
    WHEN event."FROM_COMMUNITY" = 1 THEN 'Yes'
    END AS "From Community"
    ,LISTAGG(club_name, ',') WITHIN GROUP ( ORDER BY club_name) AS clubs
  FROM event
  LEFT JOIN (club_event INNER JOIN club ON club_event.club_id = club.club_id)
  ON event.event_id = club_event.event_id
  GROUP BY event."EVENT_ID"
       ,event."EVENT_NAME"
       ,event."START_DATE"
       ,event."END_DATE"
       ,event."START_TIME"
       ,event."END_TIME"
       ,event."DESCRIPTION"
       ,event."FROM_COLLEGE"
       ,event."FROM_COMMUNITY"
  /
  </code></pre>
  
  <p>Thank you.</p>