I tried :
rc = sqlite3_prepare_v2(metadata_db,
"INSERT INTO metadata VALUES "
"( ?1, ?2, ?3, ?4 ); COMMIT;",
-1, &sthl, NULL);
But this didn't helped.
Anyway, thanks for your help.
Olivier
Hoover, Jeffrey a écrit :
> is autocommit on?
> try adding a manual commit.
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Olivier FAURAX
> Sent: Thursday, March 19, 2009 10:56 AM
> To: General Discussion of SQLite Database
> Subject: [sqlite] What am I doing wrong ?
>
> Hello,
>
> I'm beginner and uses sqlite3.
> I'm trying to record informations in a database, but this fails.
> I have followed http://www.sqlite.org/c3ref/stmt.html
>
> rc = sqlite3_open(DB_FILENAME, &metadata_db);
> rc = sqlite3_exec(metadata_db,
> "CREATE TABLE IF NOT EXISTS metadata "
> "( filename TEXT, key INT, data BLOB, length INT);",
> NULL, NULL,
> &error);
> rc = sqlite3_prepare_v2(metadata_db,
> "INSERT INTO metadata VALUES "
> "( ?1, ?2, ?3, ?4 );",
> 0, &sthl, NULL);
> rc = sqlite3_bind_text(sthl, 1, filename, 12, NULL);
> rc = sqlite3_bind_int(sthl, 2, key);
> rc = sqlite3_bind_blob(sthl, 3, data, data_length, NULL);
> rc = sqlite3_bind_int(sthl, 4, data_length);
> rc = sqlite3_step(sthl);
> rc = sqlite3_finalize(sthl);
> rc = sqlite3_close(metadata_db);
>
> I checked all "rc", they are all 0, except sqlite3_step returns 101 (aka
> SQLITE_DONE) which is correct according to doc.
>
> The problem is that I obtain a correct database (with 4 fields), but
> nothing in it. If I retry this code with an existing database, I still
> have the table, but nothign in it.
>
> The only working case is when I add a dummy sqlite3_exec before the
> close : this way, the statement is executed (I see data in the db), but
> the dummy sqlite3_exec isn't executed (it's a simple INSERT).
> This suggests that there is a kind of "flushing" that must be done, and
> that it has been done to exec the new sqlite3_exec.
>
> Please let me know what I did wrong.
>
> Have a nice day
--
Au bout de la chaîne de gestion des priorités
Olivier FAURAX | +33 4 42 98 11 20 (243 en interne)
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users