[Sqlrelay-discussion] the inputBindString posts the last value into the destination table repeatly
Brought to you by:
mused
|
From: Sha Li J. <lig...@sh...> - 2007-10-02 15:06:43
|
hi all:
I wroten a simple C program to test the inputBindString function of
the sqlrelay , the destination table was created in a mysql database .
its table structure is term_no varchar(3), order_no varchar(4),
book_name varchar(120), publisher varchar(10), and the C program
contains follow source code to insert values into the table,
#include <sqlrelay/sqlrclientwrapper.h>
#include <string.h>
int main(){
char *body;
sqlrcon mysql_con = sqlrcon_alloc("192.168.1.101",5900,"",
"mydbuser","userpwd",0,1);
sqlrcur mysql_cur = sqlrcur_alloc(mysql_con);
sqlrcur_prepareQuery( mysql_cur, "insert into kb values (
:term_no, :order_no, :book_name, :publisher )" );
strcpy( body, "079" );
sqlrcur_inputBindString( mysql_cur, "term_no", body );
strcpy( body, "0002" );
sqlrcur_inputBindString( mysql_cur, "order_no", body );
strcpy( body, "abcd" );
sqlrcur_inputBindString( mysql_cur, "book_name", body );
strcpy( body, "zxvf" );
sqlrcur_inputBindString( mysql_cur, "publisher", body );
sqlrcur_executeQuery( mysql_cur );
sqlrcon_commit( mysql_con );
sqlrcur_free( mysql_cur );
sqlrcon_free( mysql_con );
}
but the result of inserting is incorrect , the "zxvf" was filled in all
of columns, in other words, the last value of the inputBindString was
inserted by the executeQuery repeatly.
term_no order_no book_name publisher
====================================
zxv zxvf zxvf zxvf
I could not find any mistakes in my source code, the result is so strange
that I have no idea, anybody could help me ? thank you.
|