Skip site navigation (1) Skip section navigation (2)


From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Thomas Kellerer *EXTERN*" <spam_eater(at)gmx(dot)net>,<pgsql-jdbc(at)postgresql(dot)org>
Date: 2009-07-14 09:47:41
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Thomas Kellerer wrote:
> when using the RETURNING clause in a DELETE statement the 
> driver throws an error:
> org.postgresql.util.PSQLException: A result was returned when 
> none was expected.
> The code that I'm using is as follows:
> Statement stmt = connection.createStatement();
> stmt.executeUpdate("delete from person where firstname like 'A%' returning id");
> Am I missing something or is the "RETURNING" feature not 
> supported by the driver?
> I'm using postgresql-8.4-701.jdbc3.jar with Java5

That's easy; when you issue an SQL statement that returns a result,
you cannot use executeUpdate(java.lang.String).

Use executeQuery(java.lang.String) or execute(java.lang.String) and then getResultSet().

It does not matter whether the statement starts with SELECT or DELETE, the important
point is whether it returns a result set or not.

See for reference:

Laurenz Albe

In response to

pgsql-jdbc by date

Next:From: devAng@libero.itDate: 2009-07-15 09:46:25
Subject: SSL & client config.
Previous:From: Ken JohansonDate: 2009-07-14 06:42:53
Subject: An eta for ResultSetMetaData getTableName, getSchemaName, getCatalogName?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group