The cci_bind_param function binds data in the bind variable of prepared statement. Converts value of the given a_type to an actual binding type and stores it. Subsequently, whenever cci_execute() is called, the stored data is sent to the server. If cci_bind_param() is called multiple times for the same index, the last set value is configured.
If NULL is bound to the database, there can be two scenarios.
If CCI_BIND_PTR is configured for flag, the pointer of value variable is copied (shallow copy), but no value is copied. If it is not configured for flag, the value of value variable is copied (deep copy) by allocating memory. If multiple columns are bound by using the same memory buffer, CCI_BIND_PTR must not be configured for the flag.
T_CCI_A_TYPE is a C language type that is used in CCI applications for data binding, and consists of primitive types such as int and float and user-defined types defined by CCI such as T_CCI_BIT and T_CCI_DATE. The identifier for each type is defined as shown in the table below.
a_type |
value Type |
---|---|
CCI_A_TYPE_STR |
char* |
CCI_A_TYPE_INT |
int* |
CCI_A_TYPE_FLOAT |
float* |
CCI_A_TYPE_DOUBLE |
double* |
CCI_A_TYPE_BIT |
T_CCI_BIT* |
CCI_A_TYPE_SET |
T_CCI_SET* |
CCI_A_TYPE_DATE |
T_CCI_DATE* |
CCI_A_TYPE_BIGINT |
int64_t* |
CCI_A_TYPE_BLOB |
T_CCI_BLOB |
CCI_A_TYPE_CLOB |
T_CCI_CLOB |
T_CCI_U_TYPE is a column type of database to convert binding data by the value argument. For the definition of the identifier for each type, see the table below.
The reason these types are used is to inform information converting convert A-type data which C language can interpret into U-type data which database can interpret. There are various A-type data that are allowed by U-type data. For example, CCI_U_TYPE_INT can receive CCI_A_TYPE_STR as A-type data including CCI_A_TYPE_INT. For information on type conversion, see "CUBRID SQL Guide > Data Types > Implicit Type Conversion > Rules."
Both T_CCI_A_TYPE and T_CCI_U_TYPE enum(s) are defined in the cas_cci.h file. The definition of each identifier is described in the table below.
u_type |
Corresponding a_type (default) |
---|---|
CCI_U_TYPE_CHAR |
CCI_A_TYPE_STR |
CCI_U_TYPE_STRING |
CCI_A_TYPE_STR |
CCI_U_TYPE_NCHAR |
CCI_A_TYPE_STR |
CCI_U_TYPE_VARNCHAR |
CCI_A_TYPE_STR |
CCI_U_TYPE_BIT |
CCI_A_TYPE_BIT |
CCI_U_TYPE_VARBIT |
CCI_A_TYPE_BIT |
CCI_U_TYPE_NUMERIC |
CCI_A_TYPE_STR |
CCI_U_TYPE_INT |
CCI_A_TYPE_INT |
CCI_U_TYPE_SHORT |
CCI_A_TYPE_INT |
CCI_U_TYPE_MONETARY |
CCI_A_TYPE_DOUBLE |
CCI_U_TYPE_FLOAT |
CCI_A_TYPE_FLOAT |
CCI_U_TYPE_DOUBLE |
CCI_A_TYPE_DOUBLE |
CCI_U_TYPE_DATE |
CCI_A_TYPE_DATE |
CCI_U_TYPE_TIME |
CCI_A_TYPE_DATE |
CCI_U_TYPE_TIMESTAMP |
CCI_A_TYPE_DATE |
CCI_U_TYPE_OBJECT |
CCI_A_TYPE_STR |
CCI_U_TYPE_BIGINT |
CCI_A_TYPE_BIGINT |
CCI_U_TYPE_DATETIME |
CCI_A_TYPE_DATE |
int cci_bind_param(int req_handle, int index, T_CCI_A_TYPE a_type, void *value, T_CCI_U_TYPE u_type, char flag)