Re: C API to get Output value
Posted by: Hasani Blackwell
Date: December 31, 2005 03:46PM

Here's one way I found via debugging the mysql.net connector code.


Say I have the following stored procedure:

CREATE PROCEDURE `get_user_count`(OUT user_count INT)
BEGIN
SELECT COUNT(*) INTO `user_count` FROM `user`;
END

//initialize a stmt
mysql_stmt_init()

//execute the stored proc
mysql_real_query("call mysql.get_user_count(@71bb8831c92e487b9078b40837a36558)")

//create a new stmt using the same mysql_handle
mysql_stmt_init()

//get the out parameter of the stored proc
mysql_real_query("select @71bb8831c92e487b9078b40837a36558")
mysql_use_result()

//go to 1st row of results which will an array with 2 elements..The parameter name, and the value. The parameter name in this case is @71bb8831c92e487b9078b40837a36558")
mysql_fetch_row()


I chose a guid as a parameter name because I believe reusing parameter names within the same session can cause conflicts.

Options: ReplyQuote


Subject
Views
Written By
Posted
740
December 04, 2005 04:20PM
Re: C API to get Output value
443
December 31, 2005 03:46PM
359
January 01, 2006 03:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.