473,657 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get result set from calling procedure?

Hi,all
I am using Mysql 5.0 But I get an error message for calling procedure
with mysql_query().
My program is shown below:
Thank & Regard.
Gary.

#define W32_LEAN_AND_ME AN
#include <windows.h>
#include <mysql.h>
#include <stdio.h>
#include <string>

int main(int argc, char** argv)
{
MYSQL* sqlid = mysql_init(0);
if (!mysql_real_co nnect(sqlid, "localhost" , "test", "test", "test", 0,
0, CLIENT_MULTI_ST ATEMENTS)) {
printf("%s\n", mysql_error(sql id));
mysql_close(sql id);
return -1;
}
sqlid->reconnect = 1;
std::string proc = "call pro_ins_departm ent(10, 'test',
'testprocedure' )";
if (0 != mysql_query(sql id, proc.c_str())) {
printf("operato r failed:%d %s\n", mysql_errno(sql id),
mysql_error(sql id));
} else {
MYSQL_RES * rs = mysql_store_res ult (sqlid);
MYSQL_ROW row = mysql_fetch_row (rs);
unsigned __int64 id = (unsigned __int64)atoi(ro w[0]);
printf("get id:id=%d\n", id);
}
mysql_close(sql id);
return 0;
}

Aug 15 '06 #1
2 5934
Gary li wrote:
Hi,all
I am using Mysql 5.0 But I get an error message for calling procedure
with mysql_query().
My program is shown below:
Thank & Regard.
Gary.

#define W32_LEAN_AND_ME AN
#include <windows.h>
#include <mysql.h>
#include <stdio.h>
#include <string>

int main(int argc, char** argv)
{
MYSQL* sqlid = mysql_init(0);
if (!mysql_real_co nnect(sqlid, "localhost" , "test", "test", "test", 0,
0, CLIENT_MULTI_ST ATEMENTS)) {
printf("%s\n", mysql_error(sql id));
mysql_close(sql id);
return -1;
}
sqlid->reconnect = 1;
std::string proc = "call pro_ins_departm ent(10, 'test',
'testprocedure' )";
if (0 != mysql_query(sql id, proc.c_str())) {
printf("operato r failed:%d %s\n", mysql_errno(sql id),
mysql_error(sql id));
} else {
MYSQL_RES * rs = mysql_store_res ult (sqlid);
MYSQL_ROW row = mysql_fetch_row (rs);
unsigned __int64 id = (unsigned __int64)atoi(ro w[0]);
printf("get id:id=%d\n", id);
}
mysql_close(sql id);
return 0;
}
you have to make sure that you the username you're using has execute
privileges on that stored procedure in the database you're connecting
to. otherwise, it looks ok to me.
Aug 15 '06 #2
But It's still the same error for using root username.

lark 写道:
Gary li wrote:
Hi,all
I am using Mysql 5.0 But I get an error message for calling procedure
with mysql_query().
My program is shown below:
Thank & Regard.
Gary.

#define W32_LEAN_AND_ME AN
#include <windows.h>
#include <mysql.h>
#include <stdio.h>
#include <string>

int main(int argc, char** argv)
{
MYSQL* sqlid = mysql_init(0);
if (!mysql_real_co nnect(sqlid, "localhost" , "test", "test", "test", 0,
0, CLIENT_MULTI_ST ATEMENTS)) {
printf("%s\n", mysql_error(sql id));
mysql_close(sql id);
return -1;
}
sqlid->reconnect = 1;
std::string proc = "call pro_ins_departm ent(10, 'test',
'testprocedure' )";
if (0 != mysql_query(sql id, proc.c_str())) {
printf("operato r failed:%d %s\n", mysql_errno(sql id),
mysql_error(sql id));
} else {
MYSQL_RES * rs = mysql_store_res ult (sqlid);
MYSQL_ROW row = mysql_fetch_row (rs);
unsigned __int64 id = (unsigned __int64)atoi(ro w[0]);
printf("get id:id=%d\n", id);
}
mysql_close(sql id);
return 0;
}
you have to make sure that you the username you're using has execute
privileges on that stored procedure in the database you're connecting
to. otherwise, it looks ok to me.
Aug 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5545
by: Robin Tucker | last post by:
Hi, I have one stored procedure that calls another ( EXEC proc_abcd ). I would like to return a result set (a temporary table I have created in the procedure proc_abcd) to the calling procedure for further manipulation. How can I do this given that TABLE variables cannot be passed into, or returned from, a stored procedure? Thanks,
5
6794
by: adolf garlic | last post by:
Im trying to return xml from sql. The xml is made up of different fragments, some using FOR XML ... syntax. The result is a valid xml doc. There is a working stored proc that returns the xml In .net i'm having problems loading this up. I've now tried installing sqlxml managed classes and the following appears to work when stepping through, but the result just disappears.
5
5155
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value 'D11' to :workdept and I have checked in the table that 6 rows should have returned. Any ideas why no resultset is being returned. import java.sql.*; import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.io.*; // Input/Output classes
5
8671
by: Stanley Sinclair | last post by:
I have a need to return multiple result sets from a stored procedure. Want that SP to call others to get the data. Win2003, db2 8.1.5. Can't figure out how to handle open cursors, and return >1 result sets. Thought about global temp tables.
0
2533
by: Randy Foster | last post by:
We have a stored procedure (on DB2 8.1 FP5) that returns multiple result sets which we are calling from Java (WebSphere 5.0.2.8). We can call the stored procedure from the DB2 command line successfully. When we call it from WebSphere, we get the following error: Execution failed due to a distribution protocol error that caused deallocation of the conversation. A DRDA Data Stream Syntax Error was
1
1560
by: db2sysc | last post by:
All: I am writing a MAIN CALLING PROCEDURE. This call lot of procedures. Some of the CALLED PROCEDURES end with an OPEN C1 (cursor). How to I read this open cursor in my main procedure?? In java or C we can process this return cursor. But I am not sure if we can process the cursor in the MAIN CALLING PROCEDURE. Any help?
30
2269
by: Tim Marshall | last post by:
Here's the scenario, A2003, Jet back end, illustrated with some cut down code at the end of the post: A proc dims a snapshot recordset (dim rst as Dao.recordset) and opens it. There are several nested do loops, going through the records in rst using .movenext. At one point in one of the loops, we'll say the rst is at record "a". Now, another subprocedure is called, passing rst to it. In the subprocedure, the recordset goes through a...
2
3395
by: orencs | last post by:
Hi, I am using Datareader and stored procedure in C# ADO.NET. When I am running the stored procedure in the SQL Query Analyzer and recieve two rows (as I hace expected) col1 col2 0 1 0 2 4 2
0
1217
by: David Greenberg | last post by:
Hello I'm calling a stored procedure in VB6 using the "execute" command of rdoquery. Does anyone know how to check whether or not the execute command was succesfull or not. Not on the level of whether any rows were updated or selected but whether any Sql errors occured. VB picks up on any errors but I want to be able to identify them on the application level and deal with them myself. I already tried the "rowsaffected" property but that...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.