-->
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: how to excute a stored procedure with out parameters
PostPosted: Mon Feb 26, 2007 1:21 pm 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
Hibernate version:1.2.0.2003 (spring.net http://www.springframework.net/download ... 6-0202.zip )

hello,

I try to excute a stored procedure with out parameters:
Quote:



Code:
CREATE OR REPLACE PROCEDURE MY_PROC( pin1 IN DECIMAL,  pin2 IN DECIMAL, pout1 OUT DECIMAL ,pout2 OUT DECIMAL) is


Code:
<sql-query name="ExecMyProc">   
    <return-scalar column="pout1" type="Decimal"  />           
    <return-scalar column="pout2" type="Decimal" />                 
    call MY_PROC (:pin1, :pin2, pout1, pout2)
  </sql-query>                                                           
</hibernate-mapping>     



Code:
object o = session.GetNamedQuery("ExecMyProc")                                               
    .SetDecimal("pin1", 4)                                     
    .SetDecimal("pin2", 3)                                     
    .List();   


I have an exception: ORA-06576 (innerException)
Quote:
[OracleException (0x80131938): ORA-06576: ceci n'est pas un nom de fonction ou de procédure valide
]
System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) +203
System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals) +1018
System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, ArrayList& resultParameterOrdinals) +25
System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior) +142
System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) +4
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +9
NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd) +68
NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session) +271
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +280
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +83
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +62

[UncategorizedAdoException: Hibernate operation: could not execute query
[ call MY_PROC(?, ?,pout1, pout2) ]
Name: pin1 - Value: 4
Name: pin2 - Value: 3
[SQL: call MY_PROC(?, ?,pout1, pout2)]; uncategorized DataException for SQL []; ErrorCode [<no error code>]; ORA-06576: ceci n'est pas un nom de fonction ou de procédure valide
]
Spring.Data.Support.FallbackExceptionTranslator.Translate(String task, String sql, Exception exception) +85
Spring.Data.Support.ErrorCodeExceptionTranslator.Translate(String task, String sql, Exception exception) +1323
Spring.Data.NHibernate.HibernateAccessor.ConvertAdoAccessException(ADOException ex) +108
Spring.Data.NHibernate.Generic.HibernateTemplate.Execute(IHibernateCallback`1 action, Boolean exposeNativeSession) +384
Spring.Data.NHibernate.Generic.HibernateTemplate.Execute(IHibernateCallback`1 action) +108
Spring.Data.NHibernate.Generic.HibernateTemplate.Execute(HibernateDelegate`1 del) +139
Orbis.Foodservices.Services.Consumers.PersonalOrdersService.GetOrCreateOrder(String consumerId, DateTime date, Int32 mealId) in C:\projets\Agfa\Orbis.Restauration\Services.Impl\Services\Consumers\PersonalOrdersServicePartial.cs:24
Consumers_Orders_Order.get_Order() in c:\projets\Agfa\Orbis.Restauration\WebSite\Consumers\Orders\Order.master.cs:61
Consumers_Orders_Order.OnInit(EventArgs e) in c:\projets\Agfa\Orbis.Restauration\WebSite\Consumers\Orders\Order.master.cs:22
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692







And with this mapping (it's dummy I'know):

Code:
<sql-query name="ExecMyProc">   
    <return-scalar column="pout1" type="Decimal"  />           
    <return-scalar column="pout2" type="Decimal" />                     
    call MY_PROC (:pin1, :pin2, :pin1, :pin2)
  </sql-query>                                                           
</hibernate-mapping>     


No exception but no result :(

Please help. I can't change this procedure..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 5:29 am 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
Finaly I write this code and it's work:

Code:
             IDbCommand cmd = session.Connection.CreateCommand();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "pin1";
                    cmd.Connection = session.Connection;

                    IDataParameter parameterIn1 = cmd.CreateParameter();
                    parameterIn1.ParameterName = "pin1";
                    parameterIn1.Direction = ParameterDirection.Input;
                    parameterIn1.Value = 4;
                    cmd.Parameters.Add(parameterIn1);

                    IDataParameter parameterIn2 = cmd.CreateParameter();
                    parameterIn2.ParameterName = "pin2";
                    parameterIn2.Direction = ParameterDirection.Input;
                    parameterIn2.Value = 3;
                    cmd.Parameters.Add(parameterIn2);

                    IDataParameter parameterOut1 = cmd.CreateParameter();
                    parameterOut1.ParameterName = "pout1";
                    parameterOut1.Direction = ParameterDirection.Output;
                    parameterOut1.DbType = DbType.Int32;
                    cmd.Parameters.Add(parameterOut1);

                    IDataParameter parameterOut2 = cmd.CreateParameter();
                    parameterOut2.ParameterName = "pout2";
                    parameterOut2.Direction = ParameterDirection.Output;
                    parameterOut2.DbType = DbType.Int32;
                    cmd.Parameters.Add(parameterOut2);

                    cmd.ExecuteNonQuery();
                   
                    int out1 = (int)parameterOut1.Value;
                    int out2 = (int)parameterOut2.Value;


Use mapping would be better.. :(


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.