Hi,
I wrote the following simple test and wonder why sqlite_bind_parameter_count()
returns the value 2 (as expected) while the subsequent four
sqlite_bind_parameter_*() functions all return 0.
I tried it with sqlite3 versions 3.6.1 and 3.6.6, so I think there is a simple
explanation to be found in my code.
Best regards
Martin.
int execute( sqlite3* i_db, const char* i_sql )
{
char* sErrMsg = 0;
int ret = sqlite3_exec( i_db, i_sql, 0, 0, &sErrMsg );
if( ret != SQLITE_OK ) {
printf( sErrMsg );
sqlite3_free( sErrMsg );
return( -1 );
}
return( 0 );
}
char sSqlCreate[] = "CREATE TABLE IF NOT EXISTS Table0 (sKey VARCHAR(20) NOT
NULL PRIMARY KEY, sVal VARCHAR(200))";
char sSqlPrepareWrite[] = "INSERT INTO Table0 VALUES (?, ?)";
int TestDirectWritePrepared( )
{
sqlite3* hDb;
sqlite3_stmt* stmt;
int ret = 0;
const char* p;
int i = SQLITE_VERSION_NUMBER;
// for( i = 0; i < 10; ++i ) {
ret = sqlite3_open( "MYTEST1", &hDb );
ret = execute( hDb, "BEGIN TRANSACTION CREATE_TABLE" );
ret = execute( hDb, sSqlCreate );
ret = execute( hDb, "COMMIT TRANSACTION CREATE_TABLE" );
ret = sqlite3_prepare_v2( hDb, sSqlPrepareWrite, -1, &stmt, 0 );
ret = sqlite3_bind_parameter_count( stmt );
ret = sqlite3_bind_parameter_index( stmt, "sKey" );
ret = sqlite3_bind_parameter_index( stmt, "sVal" );
p = sqlite3_bind_parameter_name( stmt, 1 );
p = sqlite3_bind_parameter_name( stmt, 2 );
return( 0 );
}
________________________________
Confidentiality note:
The information in this email and any attachment may contain confidential and
proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates
and may be privileged or otherwise protected from disclosure. If you are not
the intended recipient, you are hereby notified that any review, reliance or
distribution by others or forwarding without express permission is strictly
prohibited and may cause liability. In case you have received this message due
to an error in transmission, we kindly ask you to notify the sender immediately
and to delete this email and any attachment from your system.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users