title: I have a weird error...ORA-00933: SQL command not properly ended for APEX sql statement
body: <p>I am trying to run the following code and I get an ORA-00933 error:</p>
  
  <pre><code>&lt;code&gt; --CODE B
  select distinct po_details.po_id,
  po_details.po_det_id,
  po_details.change_order,
  po_details.start_date,
  po_details.end_date,
  po_details.po_det_amt,
  po_details.scope,
  po_details.name,
  po_details.po_status,
  po_details.wbs
  from po_details,wbs,project
  where po_details.po_id = :P230_PO_ID
  and po_details.wbs = wbs.wbs_number_id
  and wbs.po_number_id = :P230_PO_NUMBER
  and substr(wbs.wbs_number_id,1,6) = project.wbs_Sequence
  and project.project_number = nvl(substr(:F101_FPC_NUMBER,1,10),project.project_number))
  &lt;/code&gt;
  </code></pre>
  
  <p>I do not see where my SQL statement is in error.</p>
  
  <p>This SQL statement (CODE B) was an attempt to streamline code for an APEX application that errors out with the another error message only when I try to refresh the screen after a custom validation.  Very annoying.
  Originally the SQL statement (CODE A) looked like this:</p>
  
  <pre><code>&lt;code&gt; --CODE A
  select po_details.po_id,
  po_details.po_det_id,
  po_details.change_order,
  po_details.start_date,
  po_details.end_date,
  po_details.po_det_amt,
  po_details.scope,
  po_details.name,
  po_details.po_status,
  po_details.wbs
  from PO_DETAILS
  where po_details.po_id = :P230_PO_ID
  and po_details.wbs in (select distinct wbs.wbs_number_id 
  from wbs, project
  where wbs.po_number_id = :P230_PO_NUMBER
  and substr(wbs.wbs_number_id,1,6) = project.wbs_sequence
  and project.project_number = nvl(substr(:F101_FPC_NUMBER,1,10),project.project_number))
  order by po_details.change_order
  &lt;/code&gt;
  </code></pre>
  
  <p>The error message I receive for this CODE A sql statement in APEX is this:
      <code>
      report error:
      ORA-01445: cannot select ROWID from, or sample, a join view without a key-preserved    table
      ORA-06510: PL/SQL: unhandled user-defined exception
      </code></p>
  
  <p>...and people told me that if I use a view (CODE B scribble prior to view creation) it would fix this refresh error-out issue. What?  All these hoops just for a refresh? If I can figure out the ORA-00933 error message, I might be able to proceed.  It seems I'm chasing rainbows instead of getting anywhere.
  Any suggestions?
  Thanks! </p>