-->
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: Execute Oracle stored proc w/o return value or parameters
PostPosted: Sat Mar 22, 2008 11:49 am 
Newbie

Joined: Wed Dec 17, 2003 1:57 pm
Posts: 4
I want to execute a simple Oracle stored procedure that does not require any parameters nor does it return any values or result sets. It just copies data between tables and all I need to do is execute it.

In straight SQL this is all I need to do:
EXECUTE MYSCHEMA.MY_PROCEDURE

In my DAO here's how I'm trying to get Hibernate to execute the procedure:

String sql = "EXECUTE MYSCHEMA.MY_PROCEDURE";
Query query = getCurrentSession().createSQLQuery(sql);
int result = query.executeUpdate();

But when I try this approach I get this error:

Code:
40903 [main] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 900, SQLState: 42000
40903 [main] ERROR org.hibernate.util.JDBCExceptionReporter  - ORA-00900: invalid SQL statement

FAILED: testExtractTransfers
org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
   at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
   at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
   at us.or.state.doc.pre.data.PreaTransferDAO.extractNewTransfers(PreaTransferDAO.java:87)
   at us.or.state.doc.pre.service.PreaWatchListServiceImpl.extractNewTransfers(PreaWatchListServiceImpl.java:145)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy39.extractNewTransfers(Unknown Source)
   at us.state.or.doc.pre.service.PreaWatchListServiceImplTest.testExtractTransfers(PreaWatchListServiceImplTest.java:890)
   at org.unitils.UnitilsTestNG.run(UnitilsTestNG.java:128)
Caused by: java.sql.SQLException: ORA-00900: invalid SQL statement

   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
   at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
   at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
   at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
   at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
   at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
   at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
   ... 45 more
... Removed 32 stack frames



Should I just get the Connection from the Hibernate session and write my own JDBC statement to execute the procedure?


Hibernate version: Hibernate 3

Name and version of the database you are using: Oracle 10g

Output from log SQL:
EXECUTE MYSCHEMA.MY_PROCEDURE


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 11:39 am 
Newbie

Joined: Fri Jul 28, 2006 10:53 am
Posts: 15
This is likely too late to help you, but given the prominence of this thread on my Google search it should help others: changing your SQL from "execute ..." (or "exec ...") to "call ..." should make it work.


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.