2. Set the
buffer
in which you pass the temporal value.
3. Fill in the members of the
to be passed.
Use
mysql_stmt_bind_param()
mysql_stmt_execute().
To retrieve temporal values, the procedure is similar, except that you set the
to the type of value you expect to receive, and the
structure into which the returned value should be placed. Use
the buffers to the statement after calling
Here is a simple example that inserts DATE, TIME, and
assumed to be a valid connection handle.
MYSQL_TIME
MYSQL_BIND
MYSQL_STMT
strmov(query, "INSERT INTO test_table(date_field, time_field, \
stmt = mysql_stmt_init(mysql);
if (!stmt)
{
fprintf(stderr, " mysql_stmt_init(), out of memory\n");
exit(0);
}
if (mysql_stmt_prepare(mysql, query, strlen(query)))
{
fprintf(stderr, "\n mysql_stmt_prepare(), INSERT failed");
fprintf(stderr, "\n %s", mysql_stmt_error(stmt));
exit(0);
}
/* set up input buffers for all 3 parameters */
bind[0].buffer_type= MYSQL_TYPE_DATE;
bind[0].buffer= (char *)&ts;
bind[0].is_null= 0;
bind[0].length= 0;
...
bind[1]= bind[2]= bind[0];
...
mysql_stmt_bind_param(stmt, bind);
/* supply the data to be sent in the ts structure */
ts.year= 2002;
ts.month= 02;
ts.day= 03;
ts.hour= 10;
ts.minute= 45;
ts.second= 20;
mysql_stmt_execute(stmt);
..
20.6.18. C API Support for Prepared
In MySQL 5.0, prepared
one result set. Nor can the calling application use placeholders for
MySQL 5.5 expands prepared
result sets and to provide placeholder access to
C API Support for Prepared
member of the
MYSQL_BIND
MYSQL_TIME
to bind the parameter data to the statement. Then you can call
ts;
bind[3];
*stmt;
timestamp_field) VALUES(?,?,?");
statements can be used only for stored procedures that produce at most
CALL
statement support for stored procedures that produce multiple
CALL
Statements
CALL
structure to the address of the
structure that are appropriate for the type of temporal value
member to the address of a
buffer
mysql_stmt_bind_result()
mysql_stmt_execute()
TIMESTAMP
Statements
CALL
and
OUT
INOUT
2229
MYSQL_TIME
buffer_type
MYSQL_TIME
and before fetching the results.
data. The
variable is
mysql
or
parameters.
OUT
INOUT
parameters.
structure
member
to bind
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers