Oracle 5.0 Reference Manual page 2226

Table of Contents

Advertisement

CR_OUT_OF_MEMORY
Out of memory.
CR_SERVER_GONE_ERROR
The MySQL server has gone away.
CR_SERVER_LOST
The connection to the server was lost during the query.
CR_UNKNOWN_ERROR
An unknown error occurred.
Example
The following example demonstrates how to create and populate a table using mysql_stmt_init(),
mysql_stmt_prepare(), mysql_stmt_param_count(), mysql_stmt_bind_param(),
mysql_stmt_execute(), and mysql_stmt_affected_rows(). The
assumed to be a valid connection handle. For an example that shows how to retrieve data, see
Section 20.6.10.11,
#define STRING_SIZE 50
#define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table"
#define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT,\
#define INSERT_SAMPLE "INSERT INTO \
MYSQL_STMT
MYSQL_BIND
my_ulonglong
int
short
int
char
unsigned long str_length;
my_bool
if (mysql_query(mysql, DROP_SAMPLE_TABLE))
{
fprintf(stderr, " DROP TABLE failed\n");
fprintf(stderr, " %s\n", mysql_error(mysql));
exit(0);
}
if (mysql_query(mysql, CREATE_SAMPLE_TABLE))
{
fprintf(stderr, " CREATE TABLE failed\n");
fprintf(stderr, " %s\n", mysql_error(mysql));
exit(0);
}
/* Prepare an INSERT query with 3 parameters */
/* (the TIMESTAMP column is not named; the server */
/*
sets it to the current date and time) */
stmt = mysql_stmt_init(mysql);
if (!stmt)
{
fprintf(stderr, " mysql_stmt_init(), out of memory\n");
exit(0);
}
if (mysql_stmt_prepare(stmt, INSERT_SAMPLE, strlen(INSERT_SAMPLE)))
C API Prepared Statement Function Descriptions
[2942]
[2942]
[2942]
[2941]
"mysql_stmt_fetch()".
test_table(col1,col2,col3) \
VALUES(?,?,?)"
*stmt;
bind[3];
affected_rows;
param_count;
small_data;
int_data;
str_data[STRING_SIZE];
is_null;
col2 VARCHAR(40),\
col3 SMALLINT,\
col4 TIMESTAMP)"
2206
variable is
mysql

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents