本文整理汇总了C++中CppSQLite3Statement::bindNull方法的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3Statement::bindNull方法的具体用法?C++ CppSQLite3Statement::bindNull怎么用?C++ CppSQLite3Statement::bindNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppSQLite3Statement
的用法示例。
在下文中一共展示了CppSQLite3Statement::bindNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ERROR
EXPORT_C gint32 CContactDb::UpdateEntity(CDbEntity * pEntity)
{
int i;
char sql[256] = {0};
OpenDatabase();
try
{
m_dbBeluga.execDML("begin transaction;");
/* update contact entity */
strcpy(sql, "update contact set ");
for (i=1; i<ContactField_EndFlag; i++)
{
GString * fieldName = (GString*)g_ptr_array_index(m_pFieldsName, i);
strcat(sql, fieldName->str);
strcat(sql, " = ?");
if (i != ContactField_EndFlag - 1)
strcat(sql, ", ");
}
strcat(sql, "where cid = ?;");
CppSQLite3Statement statement = m_dbBeluga.compileStatement(sql);
GString * idValue = NULL;
if (ECode_No_Error == pEntity->GetFieldValue(0, &idValue))
{
statement.bind(ContactField_EndFlag, idValue->str);
g_string_free(idValue, TRUE);
}
else
statement.bindNull(ContactField_EndFlag);
for (i=1; i<ContactField_EndFlag; i++)
{
GString * fieldValue = NULL;
if (ECode_No_Error == pEntity->GetFieldValue(i, &fieldValue))
{
statement.bind(i, fieldValue->str);
g_string_free(fieldValue, TRUE);
}
else
statement.bindNull(i);
}
statement.execDML();
statement.reset();
/* update contact_ext entity */
CContact * contact = (CContact*)pEntity;
GString * fieldValue = NULL;
contact->GetFieldValue(ContactField_Type, &fieldValue);
if (ContactType_Phone == atoi(fieldValue->str))
{
CPhoneContact * phonecontact = (CPhoneContact*)pEntity;
GString * fieldId = NULL;
phonecontact->GetFieldValue(ContactField_Id, &fieldId);
memset(sql, 0, sizeof(sql));
sprintf(sql, "delete from contact_ext where cid = %d;", atoi(fieldId->str));
m_dbBeluga.execDML(sql);
/* insert phones */
GHashTable * phones = NULL;
phonecontact->GetAllPhones(&phones);
g_hash_table_foreach(phones, update_contact_ext_row, phonecontact);
g_hash_table_destroy(phones);
/* insert emails */
GHashTable * emails = NULL;
phonecontact->GetAllEmails(&emails);
g_hash_table_foreach(emails, update_contact_ext_row, phonecontact);
g_hash_table_destroy(emails);
/* insert ims */
GHashTable * ims = NULL;
phonecontact->GetAllIMs(&ims);
g_hash_table_foreach(ims, update_contact_ext_row, phonecontact);
g_hash_table_destroy(ims);
/* insert addresses */
GPtrArray * addresses = NULL;
phonecontact->GetAllAddresses(&addresses);
for (guint32 j=0; j<addresses->len; j++)
{
memset(sql, 0, sizeof(sql));
stAddress * addr = (stAddress*)g_ptr_array_index(addresses, j);
sprintf(sql, "insert into address values(NULL, %d, '%s', '%s', '%s', '%s', '%s', '%s');",
addr->atype, addr->block, addr->street, addr->district,
addr->city, addr->state, addr->country, addr->postcode);
guint32 nAddrId = m_dbBeluga.execScalar("select max(aid) from address;");
memset(sql, 0, sizeof(sql));
sprintf(sql, "insert into contact_ext values(NULL, %d, %d, %d);",
atoi(fieldId->str), addr->atype, nAddrId);
m_dbBeluga.execDML(sql);
}
freeAddressArray(addresses);
g_string_free(fieldId, TRUE);
}
g_string_free(fieldValue, TRUE);
m_dbBeluga.execDML("commit transaction;");
//.........这里部分代码省略.........