If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > call Stored Procedure in a C++ program?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-06, 09:57
Melvine Melvine is offline
Registered User
 
Join Date: Sep 2003
Posts: 24
Thumbs up call Stored Procedure in a C++ program?

Hello All,

I have following SP, which has a IN and a OUT parameter:

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`sp_test` $$
CREATE PROCEDURE `sp_test`(IN P1 INT, OUT P2 INT)
BEGIN
SET P2 = P1;
END $$

DELIMITER ;


Question:
Is it possible to call above SP inside a C++ program using MySQL's C API functions?
I tried to call following:
char* spCallStmt = "call sp_test ( ?, ? )";

After binding, then by executing, I always get trouble with the second OUT parameter:
"OUT or INOUT argument 2 for routine test.sp_test is not a variable"


Any idea?

Thanks a lot,

Mel

--------------
Some code:


int intParam1 = 0; //input parameter
int intParam2 = 0; //output parameter

MYSQL_BIND* bind = new MYSQL_BIND [2];
//First IN parameter:
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer = (char *)&intParam1;
bind[0].is_null= 0;
bind[0].length= 0;

//Second OUT parameter:
bind[1].buffer_type= MYSQL_TYPE_LONG;
bind[1].buffer = (char *)&intParam2;
bind[1].is_null= 0;
bind[1].length= 0;

retValue = mysql_stmt_bind_param(stmtHandle, bind);

retValue = mysql_stmt_execute(stmtHandle);
//"OUT or INOUT argument 2 for routine test.sp_test is not a variable"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On