hello list,

I have a question regarding prepared statements. I'm fairly new to 
sqlite3 and it's already pretty late, so if I'm overlooking 
something obvious please forgive me :) I'm on Windows 7 x64 and 
using sqlite-3070800 (amalgamation).

I'm trying to prepare an insert statement, that I will reuse many 
times using bound parameters. In a short test application, if I 
prepare the statement within the main function everything is fine:

CODE
...
int rc=0;
pDb = (sqlite3*) malloc (sizeof(sqlite3*));
stmt = (sqlite3_stmt*) malloc (sizeof(sqlite3_stmt*));
...

if((rc=sqlite3_prepare_v2(pDb, INSERT_STMT , -1, &stmt, NULL)) != 
SQLITE_OK){
                /* ... error ... */
}

sqlite3_step(stmt);
...
\CODE

However, if I try throw this code in a separate function like this,

CODE
int prepareStatement(sqlite3_stmt* stmt, sqlite3* pDb){

        int rc=0;

        if((rc=sqlite3_prepare_v2(pDb, INSERT_STMT , -1, &stmt, NULL)) != 
SQLITE_OK){
                /* ... error ... */
        }
        return 0;
}
\CODE

it fails as soon as I call sqlite3_step(stmt) afterwards. The 
debugger stops at:

sqlite3_mutex_enter(db->mutex);

At first I thought I was doing smthg wrong during memory 
allocation, but everything seems to be fine there. I'm sure I'm 
overlooking an obvious mistake. Maybe somebody can give me a hint!

thanks,
John

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

Reply via email to