Re: Moving from PHP to Java: A result was returned when none was expected.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Moving from PHP to Java: A result was returned when none was expected.
Date: 2016-06-15 19:18:57
Message-ID: CAKFQuwZSmoMGQDKKrRXbzpYxUGsrRT8kQUfeZPsXE73AEe2jbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 15, 2016 at 3:07 PM, Alexander Farber <
alexander(dot)farber(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2016-06-15 19:19:41 Re: Index seems "lost" after consecutive deletes
Previous Message Adrian Klaver 2016-06-15 19:11:40 Re: Fwd: regarding schema only migration from sqlserver to postgres with runmtk.sh