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

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-14 06:28:39
Message-ID: h3h8im$vmi$1@ger.gmane.org (view raw or flat)
Thread:
Lists: pgsql-jdbc
Oliver Jowett, 14.07.2009 00:35:
> I took another look at this, and your code assumes that the update count
> is the first result. It's not. In the case where both a resultset and an
> update count are present in a single query, the driver puts the
> resultset result first (so that executeQuery() works nicely).
> 
> So your first call to getUpdateCount() returns -1 because the current
> result is a resultset, not an update count (see the javadoc). Then you
> call getMoreResults() which moves to the 2nd result (the update count)
> and returns false because there's no resultset (again, see the javadoc).
>
> If you want a general-purpose result processing loop

The perils of quick and dirty test programs... 

I actually have that generic loop already, just failed to think it through completely before posting ;) 

Sorry for the trouble and thanks for the help.

Regards
Thomas


In response to

pgsql-jdbc by date

Next:From: Ken JohansonDate: 2009-07-14 06:42:53
Subject: An eta for ResultSetMetaData getTableName, getSchemaName, getCatalogName?
Previous:From: Oliver JowettDate: 2009-07-13 22:35:31
Subject: Re: DELETE ... RETURNING

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