I have this
DECLARE
c number;
BEGIN
c := get_next_unlocked_id();
DBMS_OUTPUT.put_line('id: ' || c);
END;
This query print function result. But I need return this result in my Spring data JPA repositoru or entitiManager.
I try this:
@Override
public Long getOld() {
Long id = (Long) em.createNativeQuery("SELECT get_next_unlocked_id() FROM DUAL").getSingleResult();
return id;
}
but I get error:
2019-01-10 15: 28: 25.768 ERROR 6724 --- [pool-1-thread-2] o.h.engine.jdbc.spi.SqlExceptionHelper: ORA-14551: the DML operation cannot be performed inside the request
ORA-06512: on "MY.GET_NEXT_UNLOCKED_ID", line 8
The function you are calling in a select ( get_next_unlocked_id
) attempts to do data modification , which is not allowed the way you tried it.
The problem is that your solution appears to be "querying" while in effect it is modifying data. I assume your function increments some counter or updates something? The ORA errorcode you received is quite descriptive, here is the longer explanation .
The solution either way is to use CallableStatements from Java.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.