4

I am really stuck here, every time I am calling procedure hibernate is showing error

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

Can anyone help me out from 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; 

Hibernate

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 {
..........
.......... 
}

Hibernate errors are below

java.sql.SQLException: Cannot perform fetch on a PLSQL statement: next

1 Answer 1

-1

The stored procedure just prints the result of the query, it does not return it. So you can't get its result in Java/Hibernate.

3
  • Could you please correct the SP for return results? @cris
    – Don
    Commented Jan 17, 2015 at 12:19
  • Stored procedure can return the result of a query and we can get it in Java/Hibernate
    – rachana
    Commented Apr 9, 2015 at 5:23
  • @rachana I was referring to the stored procedure which was provided by the user who asked the question. I was not saying that stored procedure in general cannot return results.
    – cris23
    Commented Apr 28, 2015 at 7:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.