Paul J Stevens wrote:
That was my point. I *need* to used executeQuery to enable the postgres work-around. Remember that my code needs to work for all backends. Using executeQuery works for both postgres (using the returned resultset) as well as for mysql (getting lastRowId directly).
I've figured out what was wrong. I need to call ResultSet_next() before I can determine the lastRowId() after calling executeQuery. Makes sense after reading the code. (sqlite3_step only being called from ResultSet_next).
However, using this pattern means I have to a full Connection_preparedStatement, PreparedStatement_setXXX, PreparedStatement_executeQuery, Connection_clear for each row I insert where I need to obtain the ROWID. More room for improvement, imo.
This makes me suspicious a more general rule may apply: can I re-use a prepared statement that returns a result set? I suspect not, at least not for sqlite....