6.4.26 mysql_stmt_send_long_data ()

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 -最流行的开源数据库”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); }