-->
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.  [ 1 post ] 
Author Message
 Post subject: Stored procedure with OUT parameter not first?
PostPosted: Fri Jan 14, 2011 11:12 am 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
The doc says:
The stored procedure/function must return a resultset as the first out-parameter to be able to work with Hibernate.

And a bit later:
For Oracle the following rules apply:
- A function must return a result set. The first parameter of a procedure must be an OUT that returns a result set.

So having a second parameter for OUT in a procedure is not supported with Oracle.
I can confirm that with:
Code:
   <sql-query name="selectAllEventsLike2"   callable="true" >
      <return  class="org.hibernate.tutorial.hbm.Event"/>
      { call USER1.selectAllEventsLikeP(?,?)}
   </sql-query>

// java
List result =  session.getNamedQuery("selectAllEventsLike2")
      .setParameter(0, "%foo%")
      .list();

// SQL

CREATE OR REPLACE PROCEDURE selectAllEventsLikeP (
    in_title_pat in varchar2,
    st_cursor out SYS_REFCURSOR )
AS
BEGIN
    OPEN st_cursor FOR
SELECT EVENT_ID,
EVENT_DATE,
TITLE
FROM EVENTS
WHERE TITLE LIKE in_title_pat;
END;

This works.

Using second parameter for out does not:
Code:
   <sql-query name="selectAllEventsLike2"   callable="true" >
      <return  class="org.hibernate.tutorial.hbm.Event"/>
      { call USER1.selectAllEventsLikeP(?,?)}
   </sql-query>

// java
List result =  session.getNamedQuery("selectAllEventsLike2")
      .setParameter(1, "%foo%")
      .list();

// SQL

CREATE OR REPLACE PROCEDURE selectAllEventsLikeP (
    st_cursor out SYS_REFCURSOR,
    in_title_pat in varchar2
)
AS
BEGIN
    OPEN st_cursor FOR
SELECT EVENT_ID,
EVENT_DATE,
TITLE
FROM EVENTS
WHERE TITLE LIKE in_title_pat;
END;



What amount of work would be required to support procedures, that use an OUT parameter that is not the first?
Patch the Oracle dialect support code?
More?


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

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.