Re: DELETE ... RETURNING

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DELETE ... RETURNING
Date: 2009-07-13 20:23:04
Message-ID: h3g536$kq4$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Dennis Brakhane wrote on 13.07.2009 21:51:
>> Am I missing something or is the "RETURNING" feature not supported by the
>> driver?
>
> executeUpdate by definitionem can only return an int, the number of
> rows affected.

True, but the JDBC API also defines Statement.getMoreResults() and
Statement.getResultSet() which could be used to return that information

At least executeUpdate() should not throw an exception.

> You probably can use stmt.executeQuery instead

Actually execute() works without throwing an exception, but getMoreResults() and
getResultSet() do not return the information about the deleted rows.

Additionally when using execute(), getUpdateCount() will return -1 even if rows
were deleted.

Thomas

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Rees 2009-07-13 21:20:06 Re: Java long
Previous Message Dennis Brakhane 2009-07-13 19:51:01 Re: DELETE ... RETURNING