-->
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.  [ 4 posts ] 
Author Message
 Post subject: Stoed Procedure an Id Generation
PostPosted: Tue May 30, 2006 5:51 am 
Newbie

Joined: Fri Feb 10, 2006 11:19 am
Posts: 5
I need to call the following stored procedure to generate a unique identifer. Is there a way I can call this directly from the mapping files.


/*
* Stored procedures to generate unique keys
*/

create procedure opc_get_key (@keyname char(10),
@newvalue int = -1 output)
as
BEGIN TRANSACTION

UPDATE unique_keys
SET keyvalue = keyvalue + 1
WHERE keyname = @keyname

SELECT @new
value = keyvalue
FROM unique_keys
WHERE keyname = @keyname

SELECT @newvalue

COMMIT TRANSACTION

return


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 2:23 pm 
Newbie

Joined: Tue May 30, 2006 12:37 pm
Posts: 2
Location: Oregon, USA
Hi. Are you using Hibernate 3?

If you are, see instructions and rules of use in the online reference (section 16.3.2 "Using stored procedures for querying") It explains how you can use
Code:
<sql-query ...
</sql-query>
in your mapping to map to a stored procedure ...... http://www.hibernate.org/hib_docs/v3/re ... /#sp_query


I hope this helps.


Top
 Profile  
 
 Post subject: How to call stored procedure???
PostPosted: Mon Jun 12, 2006 10:03 pm 
Newbie

Joined: Fri Jun 09, 2006 5:52 am
Posts: 4
the online reference seems like doesn't help much in calling the stored procedure as the example just showing how to configure the <sql-query> for stored function but not procedure, so could anyone can ellaborate more on how to calling the stored procedure?

Besides, as mentioned in the referene, "The stored procedure/function must return a resultset as the first out-parameter".
Does that mean it is only return cursor type instead of string or integer for all type of databases such as MS SQL server, Oracle and MYSQL???

As what I know there is no way for MYSQL stored procedure/function to return cursor type, is there any turn around solution on this?

Sorry for I suppose to answer the question here but it seems I was getting confuse and confuse after read through the reference and now seeking for help from other.

Hope someone can help, thanks in advanced.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 21, 2006 2:05 pm 
Newbie

Joined: Wed Jun 21, 2006 2:02 pm
Posts: 6
Location: Carlsbad, CA
Did you identify a way to use <sql-query> to invoke an Oracle Stored Procedure which does NOT return a ref cursor, but a scalar value instead?


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