Re: [sqlite] update of a blob
On Mon, 2011-02-21 at 15:13 +0100, Dietmar Hummel wrote: > std::string strStatement( "UPDATE persistence SET > name=\"blub\",expiration=\"2011-04-02\",value=\"?\" WHERE id=\"1\"" ); In addition to what Igor said, it isn't really proper (standard?) SQL to put double quotes around the value literals because these should be reserved for identifiers (e.g. schema, column or table names). I know that MS-Access (and probably SQL Server) allows it; perhaps SQLite does, too, but other databases won't -- you need to enclose them in single quotes (but only if the value is a string literal, or a date-time value formatted as a string). With some RDBMS's the character used to enclose identifiers is optional or configurable, e.g. the backtick character (`) used by MySQL. Bob ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] update of a blob
Dietmar Hummel wrote: > Maybe someone could help me with a little problem. I am trying to update > an existing entry in the db > with an update statement where one of the columns is a blob type. I have > code that looks like this: > > sqlite3_stmt* m_pStatement = NULL; > > std::string strStatement( "UPDATE persistence SET > name=\"blub\",expiration=\"2011-04-02\",value=\"?\" WHERE id=\"1\"" ); std::string strStatement( "UPDATE persistence SET name='blub',expiration='2011-04-02',value=? WHERE id=1" ); '?' (let alone "?") is not a parameter placeholder - it's a string literal consisting of a single character ?. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] update of a blob
Hi list! Maybe someone could help me with a little problem. I am trying to update an existing entry in the db with an update statement where one of the columns is a blob type. I have code that looks like this: sqlite3_stmt* m_pStatement = NULL; std::string strStatement( "UPDATE persistence SET name=\"blub\",expiration=\"2011-04-02\",value=\"?\" WHERE id=\"1\"" ); int iResult = sqlite3_prepare_v2( m_pHandle, strStatement.c_str(), strStatement.length() + 1, &m_pStatement, NULL ); /* error checking is done here */ !! the error is on the following line. Whatever I enter for the index counter variable, I always get the error: "bind or column index out of range" iResult = sqlite3_bind_blob( m_pStatement, 0, p_bsValue.data(), p_bsValue.length(), SQLITE_TRANSIENT ); /* here again error checking */ iResult = sqlite3_step( m_pStatement ); /* here again error checking */ //dh done sqlite3_finalize( m_pStatement ); Maybe someone could give me a hint? Regards Dietmar ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users