bool open();
void close();
+ sqlite3_stmt* prepare_query(char *query);
+ bool query_bind_text(sqlite3_stmt* pStmt, int pos, const char *app_id);
+ bool execute(sqlite3_stmt* pStmt);
bool execute(const std::string& query, const std::string& columnTypes, std::vector<std::string>* columnNames, std::vector<std::shared_ptr<Tuple>>* queryResult);
bool execute(const std::string& query, std::vector<std::shared_ptr<Tuple>>* queryResult);
return E_NONE;
}
+bool Database::query_bind_text(sqlite3_stmt* pStmt, int pos, const char *app_id)
+{
+ _I("query_bind_text");
+
+ IF_FAIL_RETURN_TAG(pStmt, false, _E, "prepared statement is NULL");
+ IF_FAIL_RETURN_TAG(app_id, NULL, _E, "app_id is NULL");
+
+ int rc = -1;
+
+ rc = sqlite3_bind_text(pStmt, pos, app_id, strlen(app_id), SQLITE_STATIC);
+
+ IF_FAIL_RETURN_TAG((SQLITE_OK == rc), false, _E, "sqlite3_bind_text fail, rc : %d\n", rc);
+
+ return true;
+}
+
+sqlite3_stmt* Database::prepare_query(char *query)
+{
+ _I("prepare_query");
+
+ IF_FAIL_RETURN_TAG(__dbHandle, NULL, _E, "Not opened");
+ IF_FAIL_RETURN_TAG(query, NULL, _E, "query is NULL");
+
+ int rc = -1;
+ sqlite3_stmt* pStmt = NULL;
+
+ rc = sqlite3_prepare_v2(__dbHandle, query, strlen(query), &pStmt, NULL);
+
+ IF_FAIL_RETURN_TAG((SQLITE_OK == rc), NULL, _E, "sqlite3_prepare_v2 fail, rc : %d\n", rc);
+
+ return pStmt;
+}
+
+bool Database::execute(sqlite3_stmt* pStmt)
+{
+ _I("execute with prepared statement");
+
+ IF_FAIL_RETURN_TAG(pStmt, false, _E, "prepared statement is NULL");
+
+ int rc = -1;
+
+ rc = sqlite3_step(pStmt);
+ if (rc != SQLITE_DONE) {
+ _E("sqlite3_step fail, rc : %d\n", rc);
+ } else {
+ _I("sqlite3_step Success");
+ }
+
+ rc = sqlite3_finalize(pStmt);
+ if (rc == SQLITE_BUSY) {
+ _E("sqlite3 busy = %d", rc);
+ goto END;
+ } else if (rc != SQLITE_OK) {
+ _E("sqlite3_finalize fail, rc : %d\n", rc);
+ goto END;
+ }
+
+ _I("sqlite3_finalize Success");
+ return true;
+END:
+ return false;
+}
+
bool Database::execute(const std::string& query, const std::string& columnTypes,
std::vector<std::string>* columnNames, std::vector<shared_ptr<Tuple>>* queryResult)
{