[sqlite] multiple outstanding sqlite3_stmt objects

2012-12-18 Thread Larry Brasfield
At http://www.sqlite.org/c3ref/stmt.html , there is a weak implication 
that SQLite may expect single sqlite3_stmt objects to exist for a 
connection.  The pattern I intend to follow instead of the one shown as 
life of a statement object goes something like this is:

1. Create sqlite3_stmt #1
2. Create sqlite3_stmt #2
3. Bind values to sqlite3_stmt #1
4. Execute sqlite3_stmt #1
5. Reset sqlite3_stmt #1
6. Bind values to sqlite3_stmt #2
7. Execute sqlite3_stmt #2
8. Reset sqlite3_stmt #2
9. Repeat steps 6-8 as needed
10. Repeat steps 3-9 as needed
11. Destroy sqlite3_stmt #2
12. Destroy sqlite3_stmt #1

Is there any reason not to do this?  (I would not be asking if I could 
see any hint in the API docs that sqlite3_stmt objects can be used 
independently, in arbitrary order, during their lifetimes.)


Thanks,
--
Larry Brasfield

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


Re: [sqlite] multiple outstanding sqlite3_stmt objects

2012-12-18 Thread Igor Tandetnik

On 12/18/2012 8:21 PM, Larry Brasfield wrote:

At http://www.sqlite.org/c3ref/stmt.html , there is a weak implication
that SQLite may expect single sqlite3_stmt objects to exist for a
connection.


Not sure what led you to believe this. You definitely may have multiple 
prepared statements on one connection. They are largely independent of 
each other.

--
Igor Tandetnik

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


Re: [sqlite] multiple outstanding sqlite3_stmt objects

2012-12-18 Thread Simon Slavin

On 19 Dec 2012, at 1:21am, Larry Brasfield larry_brasfi...@iinet.com wrote:

 Is there any reason not to do this?

Don't do it if one statement is a SELECT and another statement interferes with 
the normal way that _step() would step through the results.  Although the API 
will not immediately return an error when you do this you can get an error 
later on (but you will not be able to make SQLite corrupt the database this 
way*).

Having multiple prepared statements which make changes is not a problem.

Simon.

* unless there's a bug we don't know about
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users