Hello,

Le 22-nov.-06 à 20:00, Igor Tandetnik a écrit :

I try to use "sqlite3_reset()" and/or "sqlite3_clear_bindings()" before "re-binds" and "re-step" but I always get an error 21 (SQLITE_MISUSE) when I am calling them on a already used sqlite3_stmt...

sqlite3_reset should work. You are doing something wrong. Show a small complete sample that reproduces the problem.

I checked a bit too fast before sending the first mail... Based on your mail, I retried with only sqlite3_reset() and the results are a bit different...

In fact, when I only use sqlite3_reset() before making the new binds to insert a new row, I don't get any error from sqlite3_reset() but I get a SQLITE_RANGE error at the first sqlite3_bind_xxx call I make (see the sequence of sqlite3_calls() below)... As if I had to "clear the bindings" made for the first "insert"...

When I carefully re-read the "sqlite3.h" file regarding sqlite3_reset, it says "Any SQL statement variables that had values bound to them using the sqlite3_bind_*() API retain their values... That's why I was trying a "cocktail" using sqlite3_clear_bindings() after sqlite3_reset()...

sqlite3_prepare("INSERT INTO Book (author_fk,title) VALUES (?,?)") -> SQLITE_OK

        // insert first row
        sqlite3_reset()                         -> SQLITE_OK
        sqlite3_bind_xxx()                      -> SQLITE_OK
        sqlite3_bind_xxx()                      -> SQLITE_OK
        sqlite3_step                                    -> SQLITE_DONE

        // insert second row
        sqlite3_reset()                         -> SQLITE_OK
        sqlite3_bind_xxx()                      -> SQLITE_RANGE
        sqlite3_bind_xxx()
        sqlite3_step

But I confirm that if I am using only sqlite3_clear_bindings() instead of sqlite3_reset(), sqlite3_clear_bindings() produces an SQLITE_MISUSE error at the second call, as below:

sqlite3_prepare("INSERT INTO Book (author_fk,title) VALUES (?,?)") -> SQLITE_OK

        // insert first row
        sqlite3_clear_bindings()                -> SQLITE_OK
        sqlite3_bind_xxx()                      -> SQLITE_OK
        sqlite3_bind_xxx()                      -> SQLITE_OK
        sqlite3_step                                    -> SQLITE_DONE

        // insert second row
        sqlite3_clear_bindings()                -> SQLITE_MISUSE
        sqlite3_bind_xxx()
        sqlite3_bind_xxx()
        sqlite3_step

I will try to reproduce this problem tomorrow out of the C++ SQLiteLibrary that is full of objects just to isolate the sqlite3 calls...

Regards,

Luc Demarche

Reply via email to