-->
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.  [ 8 posts ] 
Author Message
 Post subject: Oracle stored procedure and parameters
PostPosted: Tue May 24, 2005 11:47 am 
Newbie

Joined: Tue May 24, 2005 11:04 am
Posts: 5
Hi,

I am having trouble with an oracle stored procedure. For some reason whenever I try to add something as a parameter it doesn't get as far as the stored procedure.

For example I have the oracle function below, (l_cur is of type REF CUR):
Code:
FUNCTION search( v_name    in varchar) RETURN search_cur_type is
    l_cur   search_cur_type;
    l_query varchar(512) default 'SELECT * FROM dbtest_user WHERE 1 = 1';
  BEGIN
    l_query := 'select * from dbtest_user where user_id = :v_name';
    OPEN l_cur FOR l_query
      using v_name;
  RETURN l_cur;
END search;


I have the following in my mapping file:
Code:
<sql-query name="search_sp" callable="true">
   <return alias="item" class="com.fmr.dbtest.persistance.ItemVO">
      <return-property name="userID" column="user_id"/>
      <return-property name="name" column="user_name"/>
      <return-property name="dob" column="dob"/>
      <return-property name="address" column="address"/>
      <return-property name="fruit" column="fav_fruit"/>
   </return>
   { ? = call pack1.search(:name) }
</sql-query>


And I call it using the following:
Code:
Query query = session.getNamedQuery("search_sp");
query.setString("name", name);
return query.list();


When I check the size of the list it is 0. However when I change the function and hardcode in a value for name I get back results as I would expect to. Also I added an insert to see if a value for parameter was getting passed in. It wasn't.

Can any one tell me where the value for the parameter is getting lost.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 11:50 am 
Newbie

Joined: Tue May 24, 2005 11:04 am
Posts: 5
Just to clarify I'm using Oracle 9i database, with Hibernate 3.0.2

Paddy


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 3:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
stacktrace?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 3:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
oh sorry it actually does execute, right ?

Then the paremeter MUST have been set otherwise oracle would have complained.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 4:29 am 
Newbie

Joined: Tue May 24, 2005 11:04 am
Posts: 5
It definitely executes. I do believe the parameter is being set but oracle just sees it as null. I checked this by inserting the passed variables into a table and they all just come up as null.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 10:11 am 
Newbie

Joined: Tue May 24, 2005 11:04 am
Posts: 5
The value of the parameter is definitely being passed into the the stored procedure. I've checked the callable statement and the value for the parameter is definitely passed in. However the value of the parameter is not getting picked up by the stored procedure.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 5:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so a driver bug

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 5:36 am 
Newbie

Joined: Tue May 24, 2005 11:04 am
Posts: 5
It works now. I'm not sure what was going on. Thanks for your help anyway.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.