Unable to reproduce the problem.  My test program is this:

--------------------
#include <stdio.h>
#include "sqlite3.h"
int main(int argc, char **argv){
  sqlite3 *db;
  if( argc!=2 ){
    fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
    return 1;
  }
  const char *zDb = argv[1];
  unlink(zDb);
  sqlite3_open(zDb, &db);
  sqlite3_exec(db, "CREATE TABLE MyTable(SomeTime);", 0, 0, 0);
  int result = sqlite3_exec(db, "begin;", (void*)0, (void*)0, (void*)0);
  if (result != SQLITE_OK)
      return 0;
  sqlite3_stmt* stmt = (void*)0;
  int ok = 1;
  if (sqlite3_prepare_v2(db, "insert into MyTable (SomeTime) values
(?);", -1, &stmt, (void*)0) != SQLITE_OK)
      ok = 0;
  if (ok && sqlite3_bind_text(stmt, 1, "2016-11-01 12:00:00", -1,
SQLITE_TRANSIENT) != SQLITE_OK)
      ok = 0;
  if (ok && sqlite3_step(stmt) != SQLITE_DONE)
      ok = 0;
  if (ok && sqlite3_finalize(stmt) != SQLITE_OK)
      ok = 0;
  if (ok)
      sqlite3_exec(db, "commit;", (void*)0, (void*)0, (void*)0);
  else
      sqlite3_exec(db, "rollback;", (void*)0, (void*)0, (void*)0);
  printf("ok=%d\n", ok);
  sqlite3_close(db);
  return 0;
}
----------

Place the above in a file named "x1.c" and compile as follows:

     gcc -g -c sqlite3.c
     gcc -g x1.c sqlite3.o -lpthread -ldl

Then run it:

     ./a.out x1.db
     ok=1

Then verify the database:

     sqlite3 x1.db .dump
     PRAGMA foreign_keys=OFF;
     BEGIN TRANSACTION;
     CREATE TABLE MyTable(SomeTime);
     INSERT INTO "MyTable" VALUES('2016-11-01 12:00:00');
     COMMIT;

The above was using exactly the 3.15.0 release on Ubuntu.

Perhaps you can suggest another way to reproduce the problem.

On 11/8/16, heribert <herib...@scharnagl.com> wrote:
>
> 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
>


-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to