2009/4/3 My Name <mylistuser1...@gmail.com>:
> I don't quite understand blobs yet so help is needed...
>
> Here's my database:
>
> CREATE TABLE foo
> (
>  a  INT,
>  b  TEXT,
>  c  BLOB
> );
>
> int write_foo(int a, char *b, void *c, size_t len)
> {
>  int i;
>  char cmd[1024];
>  sqlite3_stmt *stmt;
>
>  sprintf(cmd, "UPDATE foo SET c=? WHERE a=%d AND b='%s';", a, b);
>
>  i = sqlite3_prepare_v2(db, cmd, strlen(cmd)+1, &stmt, NULL);
>  if (i != SQLITE_OK) printf("1 i=%d\n", i);
>
>  i = sqlite3_bind_blob(stmt, 1, c, len, NULL);
>  if (i != SQLITE_OK) printf("2 i=%d\n", i);
>
>  i = sqlite3_step(stmt);
>  if (i != SQLITE_OK) printf("3 i=%d\n", i);
>
>  printf("i=%d\n", i)
>  return i;
> }
>
> What am I doing wrong here?
>
> I'm always getting "3 i=101" but if I use the command line tools and
> do "select * from foo;" I see nothing, like the database is empty and
> update didn't work.

Update is not insert. It can only cause changes to records that already exist.

Rgds,
Simon
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to