title: Oracle function to return value from select with union
body: <p>I am trying to add this function to oracle db but it keeps throwing the following errors:</p>
  <blockquote>
  <p>10/72   PLS-00049: bad bind variable 'COMMITID'</p>
  <p>12/90   PLS-00049: bad bind variable 'COMMITID'</p>
  <p>14/76   PLS-00049: bad bind variable 'COMMITID'</p>
  <p>17/16   PL/SQL: ORA-00933: SQL command not properly ended</p>
  </blockquote>
  <pre><code>CREATE OR REPLACE FUNCTION GetLatestProfileChangeDateTime(commitId IN NUMBER) 
     RETURN DATE 
     AS 
     testing DATE;
     BEGIN 
          select max(a) as dateOfChange
          INTO testing
          from
          (
          select max(created_date) a from image_set where reference_id = :commitId and created_date is not null
          union
          select max(date_of_change) a from preferred_agent_info_history where commit_id = :commitId and date_of_change is not null
          union
          select max(date_of_change) a from commit_history where commit_id = :commitId and date_of_change is not null
          )
          
          RETURN testing; 
      END;
  </code></pre>
  <p>The inner select statement works fine but when I try to implement it within a function, I can't get it to accept it. I've even tried removing the parameter binding in the select statements for a starting place but it will throw different errors.</p>