Re: DELETE ... RETURNING - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject Re: DELETE ... RETURNING
Date
Msg-id h3g536$kq4$1@ger.gmane.org
Whole thread Raw
In response to Re: DELETE ... RETURNING  (Dennis Brakhane <brakhane@googlemail.com>)
Responses Re: DELETE ... RETURNING  (Oliver Jowett <oliver@opencloud.com>)
List 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


pgsql-jdbc by date:

Previous
From: Dennis Brakhane
Date:
Subject: Re: DELETE ... RETURNING
Next
From: David Rees
Date:
Subject: Re: Java long