Currently i'm using sqlite 3.15.0.
I run into the problem that a TEXT field of a TABLE cannot be bind to a
string containing a dash. If i remove or replace the dash/dashes against
any character the prepared and bind statement works fine.
Here two code fragments. The demo table is like "create table MyTable
(SomeTime text)"
//do not work... runs into commit!! but add nothing to MyTable
int result = sqlite3_exec(validSqlite3, "begin;", nullptr, nullptr,
nullptr);
if (result != SQLITE_OK)
return;
sqlite3_stmt* stmt = nullptr;
bool ok = true;
if (sqlite3_prepare_v2(validSqlite3, "insert into MyTable
(SomeTime) values (?);", -1, &stmt, nullptr) != SQLITE_OK)
ok = false;
if (ok && sqlite3_bind_text(stmt, 1, "2016-11-01 12:00:00", -1,
SQLITE_TRANSIENT) != SQLITE_OK)
ok = false;
if (ok && sqlite3_step(stmt) != SQLITE_DONE)
ok = false;
if (ok && sqlite3_finalize(stmt) != SQLITE_OK)
ok = false;
if (ok)
sqlite3_exec(validSqlite3, "commit;", nullptr, nullptr, nullptr);
else
sqlite3_exec(validSqlite3, "rollback;", nullptr, nullptr, nullptr);
//same code as above... BUT: no dashes in the text field
//works fine... runs into commit and inserts a new row in MyTable
with column SomeTime content: "2016/11/01 12:00:00"
int result = sqlite3_exec(validSqlite3, "begin;", nullptr, nullptr,
nullptr);
if (result != SQLITE_OK)
return;
sqlite3_stmt* stmt = nullptr;
bool ok = true;
if (sqlite3_prepare_v2(validSqlite3, "insert into MyTable
(SomeTime) values (?);", -1, &stmt, nullptr) != SQLITE_OK)
ok = false;
if (ok && sqlite3_bind_text(stmt, 1, "2016/11/01 12:00:00", -1,
SQLITE_TRANSIENT) != SQLITE_OK)
ok = false;
if (ok && sqlite3_step(stmt) != SQLITE_DONE)
ok = false;
if (ok && sqlite3_finalize(stmt) != SQLITE_OK)
ok = false;
if (ok)
sqlite3_exec(validSqlite3, "commit;", nullptr, nullptr, nullptr);
else
sqlite3_exec(validSqlite3, "rollback;", nullptr, nullptr, nullptr);
Both commit results with SQLITE_OK. But only the second sample (without
dash inside the text) inserts the new row.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users