getUdateCount() vs. RETURNING clause
От | Thomas Kellerer |
---|---|
Тема | getUdateCount() vs. RETURNING clause |
Дата | |
Msg-id | hegh0m$j0f$1@ger.gmane.org обсуждение исходный текст |
Ответы |
Re: getUdateCount() vs. RETURNING clause
|
Список | pgsql-jdbc |
Hi, I'm having a problem using an UPDATE statement with a RETURNING clause. It seems I cannot retrieve the number of rows affected using getUpdateCount() This is my statement UPDATE my_table SET the_column = the_column + 1 WHERE id = = RETURNING the_column; My Java code is: PreparedStatement pstmt = con.prepareStatement(UPDATE_SQL); // the statement from above pstmt.setInt(1, 42); boolean hasResult = pstmt.execute(); if (hasResult) { ResultSet rs = pstmt.getResultSet(); if (rs != null && rs.next()) { int newId = rs.getInt(1); System.out.println("newid: " + newId); } } int affected = pstmt.getUpdateCount(); System.out.println("affected: " + affected); I do see the returned ID from the ResultSet but getUpdateCount() always returns -1 even though I know that a row was updated. What am I missing here? My Postgres version is: 8.4.1 My driver version is: PostgreSQL 8.4 JDBC4 (build 701) I'm using Java6 (1.6.0_16) Regards Thomas
В списке pgsql-jdbc по дате отправления: