These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Oracle Function and SQLGrammarException
PostPosted: Thu Jan 04, 2007 7:00 pm 
Newbie

Joined: Thu Jan 04, 2007 6:51 pm
Posts: 6
Hi,

I am newbie. I have a function created in Oracle (like selectAllEmployments example in http://www.hibernate.org/hib_docs/v3/re ... rysql.html).

Code:
CREATE OR REPLACE Function selectAllStocks()
    RETURN SYS_REFCURSOR
AS
    st_cursor SYS_REFCURSOR;
BEGIN
    OPEN st_cursor FOR
SELECT SYMBOL, CURRENT_PRICE, CHANGE, OPEN_PRICE
FROM STOCK_MASTER;
      RETURN  st_cursor;
END;



The named query mapping is like this:

Code:
<sql-query name="selectStocks" callable="true">
     <return alias="stock" class="Stock">
        <return-property name="symbol" column="SYMBOL"/>
        <return-property name="currentPrice" column="CURRENT_PRICE"/>
        <return-property name="change" column="CHANGE"/>
        <return-property name="openPrice" column="OPEN_PRICE"/>
     </return>   
        { ? = call selectAllStocks() }
  </sql-query>



When I call the named query, I get a SQLGrammarException.

Code:
return session.getNamedQuery("selectStocks").list();


I am able to execute the function within sqldeveloper and is simple.

Could anyone help me find the reason?

Thanks


Top
 Profile  
 
 Post subject: sql-query
PostPosted: Fri Jan 05, 2007 5:01 am 
Beginner
Beginner

Joined: Wed Aug 31, 2005 3:54 am
Posts: 45
The declaration seems to be correct.
Is there any possibility that the oracle user use for jdbc connection not have right to execute this function ?

Don't forget to rate ;-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.