[완료]C에서 Mysql SP를 어떻게 호출 하나요..?

조야의 이미지

int main(){
int param_count;
char koo_id[256];
unsigned long length[1];
my_bool is_null[1];
my_bool error[1];
int co;
MYSQL_STMT *stmt;
MYSQL_BIND bind[1];
MYSQL_RES *result;
MYSQL *connection, mysql, mysql2;

mysql_init(&mysql);
connection = mysql_real_connect(&mysql, "localhost","linkage","linkage","linksms",3306,NULL,0);

if(connection == NULL)
{
printf(mysql_error(&mysql));
printf("\n");
exit(0);
}

stmt = mysql_stmt_init(&mysql);
if (!stmt)
{
printf("Memory Error\n");
exit(0);
}

if (mysql_stmt_prepare(stmt, SELECT_SAMPLE, (int)strlen(SELECT_SAMPLE)))
{
printf("mysql_stmt_prepare Error\n");
exit(0);
}

/*
param_count = mysql_stmt_param_count(stmt);

if (param_count != 1)
{
printf("mysql_stmt_param_count %d",param_count);
exit(0);
}*/

memset(bind,0,sizeof(bind));

bind[0].buffer_type=MYSQL_TYPE_STRING;
bind[0].buffer=(char *)koo_id;
bind[0].buffer_length=256;
bind[0].is_null=0;
bind[0].length=0;

if(mysql_stmt_bind_param(stmt, bind)){
printf("mysql_stmt_bind_param Error\n");
}

co=mysql_stmt_execute(stmt);

if(mysql_stmt_store_result(stmt)){
printf("mysql_stmt_store_result Error\n");
exit(0);
}
int row_count=0;
while (!mysql_stmt_fetch(stmt))
{
row_count++;
printf("row : %d \n", row_count);

if(is_null[0])
printf("NULL\n");
else
printf("data!!!! %s\n", koo_id);
}

printf("data!!! : %s ",koo_id);

// printf("### %d ", co);
mysql_stmt_close(stmt);
mysql_close(&mysql);
return 0;
}

저 Sp는 "select a from b " 입니다...

거의 다 따라 해봤는데 정확한 원인을 찾지 못하겠습니다..

ㅠ_ㅠ..

도와주세요~

조야의 이미지

#include
#include
#include
#include
#include
#include
#include
#include
#include

using namespace std;
#define SEC_PER_DAY 86400 // 60 * 60 * 24
#define DayOfTick(t,o) (int)((t + o) / SEC_PER_DAY)
#define REG_PROC_CALL_INTERVAL 1
#define NOW time((time_t *)NULL)
#define Tick(t) (int)(t/SEC_PER_DAY)

#define SELECT_SAMPLE "call test(@a)"
int main()
{

int param_count,column_count;
char koo_id[256];
char query[256];
unsigned long length[1];
my_bool is_null[1];
my_bool error[1];
int co,co2;

MYSQL_STMT *stmt;
MYSQL_ROW row;
MYSQL_BIND bind[1];
MYSQL_RES *result;
MYSQL *connection, mysql, mysql2;

mysql_init(&mysql);
connection = mysql_real_connect(&mysql, "localhost","linkage","linkage","linksms",3306,NULL,CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS);

stmt = mysql_stmt_init(&mysql);

if (!stmt)
{
printf("Memory Error\n");
exit(0);
}

if (mysql_stmt_prepare(stmt, SELECT_SAMPLE, (int)strlen(SELECT_SAMPLE)))
{
printf("mysql_stmt_prepare Error\n");
exit(0);
}

memset((void*)&bind,0,sizeof(bind));

bind[0].buffer_type=MYSQL_TYPE_STRING;
bind[0].buffer=(char *)koo_id;
bind[0].buffer_length=256;
bind[0].is_null=0;
bind[0].length=0;

stmt->bind = bind;

if(mysql_stmt_execute(stmt)){
printf("Mysql_error!!! : %s\n ", mysql_stmt_error(stmt));
exit(0);
}

if(mysql_stmt_bind_result(stmt, bind))
{
printf("mysql_stmt_bind_result Error : %s\n",mysql_stmt_error(stmt));
exit(0);
}

if(mysql_stmt_store_result(stmt)){
printf("mysql_stmt_store_result Error\n");
exit(0);
}

while (!mysql_stmt_fetch(stmt))
{
printf("mysql_stmt_fetch = %s\n", koo_id);
}

return 0;

}

MYSQL Korea의 예제 ㅡㅡ; 꼼꼼하게 올려주지..

호출이 안됐던거에 문제점은 저 보이드 된것.. real_connect 옵션 문제 였습니다.

http://www.mysqlkorea.co.kr/sub.html?mcode=develop&scode=01&m_no=21855&cat1=22&cat2=596&cat3=606&lang=k

real_connect 의 옵션 내용은 여기 있고..

저처럼 많이 헤메지 않았으면 좋겠어요~~

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.