MySQL Forums
Forum List  »  Stored Procedures

Re: Stored procedure problem solved
Posted by: FQ ALI
Date: July 14, 2008 03:03AM

There seems to be not a good way in c API of dealing with stored procedure out parameter.
I succeeded in getting the out parameter, but this not seems to be the best solution. If anybody knows some best way then tell me.


The following is the working code.
-------------------------

#include <mysql.h>
#include <stdio.h>
#include <string.h>

main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "";
char *user = "";
char *password = "";
char *database = "";

conn = mysql_init(NULL);

/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, CLIENT_MULTI_RESULTS | CLIENT_MULTI_STATEMENTS)) {
fprintf(stderr, "%s\n", mysql_error(conn));
//exit(0);
}

/* send SQL query */
char * state= "call PROC_NGI_Authentication30( '', '', @ret ); select @ret";

int sta =mysql_real_query(conn, state,strlen(state));


if (sta) {
fprintf(stderr, "%s\n", mysql_error(conn));
// exit(0);
}
else
{
printf("query Executed \n");
}

res = mysql_use_result(conn);
if(res==NULL)
{
printf("ResultSet NULL\n");
}
else
{
printf("Result Set Not NULL\n");
}



//int num=mysql_num_rows(res);
//printf("Number of rowssss %d \n",num);
/* while ((row = mysql_fetch_row(res)) != NULL)
{
printf("Result----------- \n");
printf("%s\n", row[1]);
}
*/
//bool b=mysql_more_results(conn);
mysql_free_result(res);

while(mysql_more_results(conn))
{
int next=mysql_next_result(conn);
printf("More Results %d \n",next);
res = mysql_use_result(conn);
if(res==NULL)
{
printf("ResultSet LOOP NULL\n");
}
else
{
printf("Result Set LOOP Not NULL\n");
}
int num=mysql_num_rows(res);
printf("Number of rowssss %d \n",num);
while ((row = mysql_fetch_row(res)) != NULL)
{
printf("Result----------- \n");
printf("lllllllllll %s\n", row[0]);
}

mysql_free_result(res);

}
//else
//printf("No More Results \n");


//mysql_free_result(res);
mysql_close(conn);

}

Options: ReplyQuote


Subject
Views
Written By
Posted
3277
July 03, 2008 06:10AM
1953
July 03, 2008 09:08AM
2342
July 03, 2008 09:48PM
2005
July 04, 2008 09:36AM
3708
July 04, 2008 06:12AM
1822
July 10, 2008 03:02AM
1846
July 10, 2008 10:51AM
2662
July 12, 2008 07:28AM
2240
July 12, 2008 03:16PM
2022
July 13, 2008 11:25PM
Re: Stored procedure problem solved
3099
July 14, 2008 03:03AM
2170
July 14, 2008 08:10AM


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.