-->
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: Calling Stored Procedure
PostPosted: Sun Jan 01, 2006 9:24 pm 
Beginner
Beginner

Joined: Wed Dec 14, 2005 10:32 am
Posts: 20
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.telcove.phoenix.picc.dao.common.PICCRecord"
dynamic-insert="false"
dynamic-update="false">

<id name="correlationID" type="string" >
<generator class="increment"/>
</id>




</class>
<sql-query name="Sp_Picc" callable="true">
<return class="com.telcove.phoenix.picc.dao.common.PICCRecord" />
{? = call Sp_Picc_Batch_Process(?,?) }

</sql-query>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Query q = session.getNamedQuery("Sp_Picc");
q.setInteger(0,1);
q.setDate(1,new Date(105,12,12));
q.setCharacter(2,'y');


List results = q.list();

for (Iterator i = results.iterator(); i.hasNext();) {
System.out.println(i.getClass());

}


Full stack trace of any exception that occurs:
[2006-01-01 20:15:29] DEBUG - 6390 - org.hibernate.util.JDBCExceptionReporter - could not execute query [

{? = call Sp_Picc_Batch_Process(?,?) }

]
java.sql.SQLException: ORA-01036: illegal variable name/number

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
at oracle.jdbc.oci8.OCIDBAccess.executeFetch(OCIDBAccess.java:1679)
at oracle.jdbc.oci8.OCIDBAccess.parseExecuteFetch(OCIDBAccess.java:1902)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:107)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1183)
at org.hibernate.loader.Loader.doQuery(Loader.java:363)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
at org.hibernate.loader.Loader.doList(Loader.java:1499)
at org.hibernate.loader.Loader.list(Loader.java:1482)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1333)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:146)
at com.telcove.phoenix.picc.common.HibernateTest.main(HibernateTest.java:68)


Name and version of the database you are using:
Oracle 9i


The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:Debug

Hi,

I have been trying to call a function and I could not escape from this error for a while.

I am trying to get the result set back from a function and many of the examples show that code need not declare the return of the resultset but when I do this..I get an error saying that i need to set 3 parameters. When I eventually set 3 of them I get the above error.

Thanks in advance.

-Ram


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 01, 2006 11:16 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
what is your function ?
you have to declare retunr value - resultset like this
CREATE OR REPLACE FUNCTION yourFunc
RETURN SYS_REFCURSOR
...


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.