How to call function using EclipseLink

空扰寡人 提交于 2019-12-04 15:39:11

I think you must specify the Direction of the functions parmeter

CREATE or REPLACE FUNCTION getEmps (username IN varchar2)
      RETURN SYS_REFCURSOR
   AS
   c_cursor   SYS_REFCURSOR;
   BEGIN
   OPEN c_cursor FOR 
   SELECT * FROM employees where emp_no=username;
   RETURN c_cursor;

Try it, please !

Save the function on database and then execute it with FUNCTION call.

For example, i have an Oracle function called 'SUMACAMPO' that sums two columns of the DB:

And my query:

select Function('SUMACAMPO') from Table t

Java Code:

Query q = em.createQuery("select Function('SUMACAMPO') from Table t");
List<Object[]> resultado= q.getResultList();
LOG.info("Resultado consulta: {}",resultado);

so, the output of execute the query in LOG is:

Resultado consulta: [4413700]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!