on 2015 Dec 04 2:58 PM
There seems to be an issue when calling the PreparedStatement.getUpdateCount() in conjunction with calling the Connection.getLastIdentity() method in UltraliteJ. You get different results depending on in which order you call them.
To illustrate using the CustDB app distributed with SA17,
ps.execute("INSERT INTO ULCustomer (cust_name) VALUES('joe')"); Log.d(this.getClass().getName(), "getUpdateCount() = " + ps.getUpdateCount()); Log.d(this.getClass().getName(), "getLastIdentity() = " + _conn.getLastIdentity());
you get the expected output,
getUpdateCount() = 1 getLastIdentity() = 1
ps.execute("INSERT INTO ULCustomer (cust_name) VALUES('joe')"); Log.d(this.getClass().getName(), "getLastIdentity() = " + _conn.getLastIdentity()); Log.d(this.getClass().getName(), "getUpdateCount() = " + ps.getUpdateCount());
you get the output,
getLastIdentity() = 1 getUpdateCount() = -1
Note the value of -1. It looks like the call to getLastIdentity() somehow destroyed the value for getUpdateCount().
Obviously I can work around this, but I think it's a bug.
Terry
Hi Terry,
Here's what's likely happening: the modified rows count is stored by the underlying UltraLite runtime in a per-request data structure, along with the error information. The call to get the last identity is a separate request, and that clears the data structure. The -1 value indicates the last request wasn't one that affects rows.
This means that if you get the update count immediately following the execute, things will be good (as you've discovered). And perhaps we should also look at improving this so it doesn't look like a bug. 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.