title: How to call a custom Oracle function returning a value from JPA
body: <p>I have a custom function in oracle returning a number after deleting records. I could get a value in sql_plus such as</p>
  
  <pre><code>call my_function(4) into :out_number;
  </code></pre>
  
  <p>where out_number is a variable defined as number.</p>
  
  <p>I could verify out_number has a value when I do "PRINT OUT_NUMBER."</p>
  
  <p>My question is how to call this function from JPA.</p>
  
  <p>I've tried like</p>
  
  <pre><code>Query query = em.createNativeQuery("{call my_function(?)}");
  query.serParameter(1, 4);
  return query.executeUpdate();
  </code></pre>
  
  <p>and got an error basically my_function is not defined. How can I get a return value as in CALL...INTO on SQL_PLUS?</p>
  
  <p>If this method is not desirable, can someone please recommend any suggestion? JPA is the only option for me at this moment. I could create a stored procedure but I'm not sure if I can get a return value from it since OUT parameters are not supported.</p>
  
  <p>Thanks for your help in advance!</p>