Java.sql.SQLException: Cannot fetch in PLSQL: next statement. In sleep mode

I'm really stuck here, every time I call, the hibernate procedure shows an error

java.sql.SQLException: Cannot perform fetch on a PLSQL statement: next when calling stored procedure from hibernate

Can someone help me with this?

Procedure

CREATE OR REPLACE PROCEDURE TESTP(
pmaxrows IN NUMBER :=3 )
AS
in_clause VARCHAR2(256);
sel_query VARCHAR2(256);
n         NUMBER := 0;
BEGIN
FOR x IN
(SELECT DISTINCT VENDOR_ID FROM MF_QUOTATIONS 
)
LOOP
IF n        <> 0 THEN
in_clause := in_clause || ', ';
END IF;
in_clause := in_clause || '''' || x.VENDOR_ID || '''';
n         := 1;
END LOOP;
sel_query := 'select * from (select ITEM_ID, VENDOR_ID, TOTAL from 
MF_QUOTATIONS) pivot (max(TOTAL) for VENDOR_ID in ('||in_clause||'));';
dbms_output.put_line (sel_query);

END TESTP; 

Sleep mode

Query q = session.getCurrentSession().getNamedQuery("callStockStoreProcedure")
        .setParameter("pmaxrows", 3);


    System.out.println("q="+q);


    List result = q.list();


    return result;

Entity class

@Entity
@Table(name="MF_QUOTATIONS")

@NamedNativeQueries({
@NamedNativeQuery(
name = "callStockStoreProcedure",
query = "CALL TESTP(:pmaxrows)",
resultClass = Quotations.class
)
})


public class Quotations {
..........
.......... 
}

Sleep errors below

java.sql.SQLException: cannot select in PLSQL statement: next

+4
source share
1 answer

The stored procedure simply prints the result of the request; it does not return it. Thus, you cannot get its result in Java / Hibernate.

-1
source

All Articles