Add OneStepExec() method to tizen_base::Database 43/285443/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 13 Dec 2022 02:50:50 +0000 (02:50 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 13 Dec 2022 03:02:12 +0000 (03:02 +0000)
To support calling the sqlite3_exec(), the method is added.

Change-Id: I9e8023690302f4c99e13f180808d109b94708bee
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
tizen-database/database.hpp

index a75c644..32140b0 100644 (file)
@@ -660,6 +660,16 @@ class Database {
     return true;
   }
 
+  void OneStepExec(const Sql& sql) const {
+    char* errmsg = nullptr;
+    int ret = sqlite3_exec(db_, sql.GetQuery().c_str(), nullptr, nullptr,
+        &errmsg);
+    if (ret != SQLITE_OK) {
+       std::unique_ptr<char, decltype(free)*> errmsg_auto(errmsg, free);
+       throw DbException(errmsg);
+    }
+  }
+
  private:
   void Bind(int pos, const DbType& type, sqlite3_stmt* stmt) const {
     int r;