[Announce] libzdb 2.1
Paul J Stevens
paul at nfg.nl
Sun Mar 2 22:09:32 CET 2008
Jan-Henrik Haukeland wrote:
> There is a minor quirk though with SQLite when using
> PreparedStatement_executeQuery(), if the Connection is used for
> further statements before it is returned to the pool, you must call
> Connection_clear() as stated in the latest change log.
>
> * API: Connection_clear() is exposed as a public method. Normally it
> is not necessary to call this method, but in some situations, if you
> use PreparedStatement_executeQuery it is necessary to call this
> function to close a prepared statement explicit. Basically, if you
> see this SQLite error, "SQL statements in progress", call this
> function to close any previous opened statements before proceeding.
I've been thinking about this. This implies that you can't use multiple
statements within a single transaction (at least with sqlite). Is that
correct? Because that would make code like below invalid, right?
PreparedStatement_T s1, s2;
ResultSet_T r;
s1 = Connection_PrepareStatement("select data from table where id=?");
s2 = Connection_PrepareStatement("update table set data=? where id=?");
while (iterator) {
PreparedStatement_setInt(s1, 1, 1000);
r = PreparedStatement_executeQuery(s1);
...
if (condition) {
PreparedStatement_setInt(s2,1,1000);
PreparedStatement_setString(s2,2,"new data");
PreparedStatement_execute(s2);
...
}
}
--
________________________________________________________________
Paul Stevens paul at nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands________________________________http://www.nfg.nl
More information about the libzdb-general
mailing list