views:

17

answers:

1

Hi there,

Can someone put more light on the functions:

sqlite3_reset();
sqlite3_clear_bindings()  

I understand that I can use sqlite3_prepare() to translate sql string to native byte code which engine understands. Therefor the engine does not have to translate it every time when it is used. I can also parametrize such prepared statement and later bind values to it with sqlite3_bind*() functions.

I can assign NULL value to these binded params with sqlite3_clear_bindings(). From documentation one can read that sqlite3_reset(), does not destroy bindings, the values are preserved and the object is put into initial state. What does it actually mean? Especially the part about not destroying bindings.

Thanks.

+1  A: 

sqlite3_reset clears the state that the prepared statement maintained during execution. This sets it back to the initial state, thus "resetting it". Bindings remain intact. The statement can be re-executed. Without resetting it, you will receive an error when you try to execute it.

sqlite3_clear_bindings will just clear the bindings, but not change the state on the prepared statement. You can't re-execute a prepared statement if you just cleared the bindings.

SB