Re: Moving from PHP to Java: A result was returned when none was expected. - Mailing list pgsql-general

From David G. Johnston
Subject Re: Moving from PHP to Java: A result was returned when none was expected.
Date
Msg-id CAKFQuwZSmoMGQDKKrRXbzpYxUGsrRT8kQUfeZPsXE73AEe2jbA@mail.gmail.com
Whole thread Raw
In response to Re: Moving from PHP to Java: A result was returned when none was expected.  (Alexander Farber <alexander.farber@gmail.com>)
List pgsql-general
On Wed, Jun 15, 2016 at 3:07 PM, Alexander Farber <alexander.farber@gmail.com> wrote:
I only understand a quarter of what you guys are writing, 
but to me the JDBC driver throwing SQLException
"A result was returned when none was expected"
when my stored function is declared as "void" with

CREATE OR REPLACE FUNCTION words_skip_game(
        IN in_uid integer,
        IN in_gid integer)
        RETURNS void AS
$func$
BEGIN

is a strange decision. Why throw the exception, what's the benefit?

Even if PostgreSQL does not have stored functions (???),
why does not JDBC driver workaround that fact?


​As far as JDBC is concerned is see a single row of data, with a single column, whose contents include a datum of type void.  It interprets this as being "a result" and thus asks you to put it somewhere.  Its doesn't treat "void" any different than, say "integer".  Whether or not it should might be worthy of a discussion but that is how it works today.

​As for the exception - I suppose its a bit of looking over the programmer's shoulder.  You wrote a query that returns data but decided to ignore the data - the driver assumes a mistake was made and throws an exception informing you of that fact.  How much of this is our decision and how much of it is specified by JDBC I do not know.​

​While void "indicates that a function returns no value​" it is itself a value; hence the dilemma.

Patches are welcome if you think there is a better way for us to operate.

David J.
 

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Fwd: regarding schema only migration from sqlserver to postgres with runmtk.sh
Next
From: Edson Richter
Date:
Subject: Re: Index seems "lost" after consecutive deletes