-->
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.  [ 3 posts ] 
Author Message
 Post subject: Store Procedure - Oracle - Parameter
PostPosted: Thu Jul 21, 2005 4:20 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.05

Mapping documents:
Code:
<sql-query name="KF_SYN_GET_NOME" callable="true">
        <return-scalar column="name"  type="string"/>
     {? = call KF_SYN_GET_NOME(?)}
</sql-query>   

Code between sessionFactory.openSession() and session.close():

1st solution:
Code:
       Query q = session.getNamedQuery("KF_SYN_GET_NOME");
       q.setString(0, uid);
       Object o = q.uniqueResult();


doesn't work with this stacktrace:

Hibernate: {? = call KF_SYN_GET_NOME(?)}
[WARN] JDBCExceptionReporter - SQL Error: 6550, SQLState: 65000
[ERROR] JDBCExceptionReporter - ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


2nd solution with same sp:
Code:
      call = session.connection().prepareCall(procedure);
      call.registerOutParameter(1, Types.VARCHAR);
      call.setString(2, uid);            
      call.execute();


It does work perfectly.

SP code:
Code:
CREATE OR REPLACE
Function KF_SYN_GET_NOME(p_user IN VARCHAR2) RETURN VARCHAR2 IS
BEGIN
    RETURN SYURP11.PKG_API.GETINFOWS(p_user, 0, 'nome');
END;
/


Why??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 9:46 am 
Newbie

Joined: Mon Apr 25, 2005 11:47 am
Posts: 5
Location: Lithuania
I believe that the 0th parameter is the out parameter. So you need to set the 1st param:

Code:
q.setString(1, uid);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 10:08 am 
Newbie

Joined: Mon Apr 25, 2005 11:47 am
Posts: 5
Location: Lithuania
ok, i was wrong :)

Quote:
For Oracle the following rules apply:
The procedure must return a result set.

For Sybase or MS SQL server the following rules apply:

The procedure must return a result set. Note that since these servers can/will return multiple result sets and update counts, Hibernate will iterate the results and take the first result that is a result set as its return value. Everything else will be discarded.


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