PDF (Ltr)- 1.3 mb
PDF (A4)- 1.3 mb
HTML下载(TGZ)- 165.5 kb
HTML下载(邮政编码)- 175.9 kb
mysql_stmt_send_long_data(MYSQL_STMT *stmt, unsigned int parameter_number, const char *data, unsigned long length)
允许应用程序将参数数据分批(或分批)发送到服务器”块”).之后调用此函数mysql_stmt_bind_param ()
之前,mysql_stmt_execute ()
.可以多次调用它来发送列的字符或二进制数据值的部分,列必须是文本
或团
数据类型。
parameter_number
指示要将数据关联到的参数。参数从0开始编号。数据
是指向缓冲区的指针,其中包含要发送的数据,和长度
指示缓冲区中的字节数。
请注意
下一个mysql_stmt_execute ()
调用忽略已使用的所有参数的绑定缓冲区mysql_stmt_send_long_data ()
自去年mysql_stmt_execute ()
或mysql_stmt_reset ()
.
要重置/忘记发送的数据,请调用mysql_stmt_reset ()
.看到部分6.4.22”mysql_stmt_reset ().
的max_allowed_packet
系统变量控制可发送的参数值的最大大小mysql_stmt_send_long_data ()
.
参数没有字符串或二进制类型。
无效的参数数量。
命令的执行顺序不正确。
MySQL服务器已经离开。
内存不足。
发生了未知错误。
下面的示例演示如何发送数据文本
列块。它插入数据值“MySQL -最流行的开源数据库”
到text_column
列。的mysql
变量被假定为有效的连接处理程序。
INSERT INTO \ test_long_data(text_column) VALUES(?)MYSQL_BIND绑定[1];长长度;支撑= mysql_stmt_init (mysql);If (!stmt) {fprintf(stderr, " mysql_stmt_init(),内存不足\n");退出(0);} if (mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY))) {fprintf(stderr, "\n mysql_stmt_prepare(), INSERT failed");Fprintf (stderr, "\n %s", mysql_stmt_error(stmt));退出(0);} memset(bind, 0, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].length= &length; bind[0].is_null= 0; /* Bind the buffers */ if (mysql_stmt_bind_param(stmt, bind)) { fprintf(stderr, "\n param bind failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* Supply data in chunks to server */ if (mysql_stmt_send_long_data(stmt,0,"MySQL",5)) { fprintf(stderr, "\n send_long_data failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* Supply the next piece of data */ if (mysql_stmt_send_long_data(stmt,0, " - The most popular Open Source database",40)) { fprintf(stderr, "\n send_long_data failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* Now, execute the query */ if (mysql_stmt_execute(stmt)) { fprintf(stderr, "\n mysql_stmt_execute failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); }