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

Поиск
Список
Период
Сортировка
Искать
От
Thomas Kellerer
Тема
Re: Moving from PHP to Java: A result was returned when none was expected.
Дата
Msg-id
njtf37$lmn$1@ger.gmane.org
Ответ на
Список
Дерево обсуждения
Moving from PHP to Java: A result was returned when none was expected. Alexander Farber <alexander.farber@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. rob stone <floriparob@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Jan de Visser <jan@de-visser.net>
Re: Moving from PHP to Java: A result was returned when none was expected. Alexander Farber <alexander.farber@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Jan de Visser <jan@de-visser.net>
Re: Moving from PHP to Java: A result was returned when none was expected. "David G. Johnston" <david.g.johnston@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Jan de Visser <jan@de-visser.net>
Re: Moving from PHP to Java: A result was returned when none was expected. "David G. Johnston" <david.g.johnston@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Alexander Farber <alexander.farber@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Jan de Visser <jan@de-visser.net>
Re: Moving from PHP to Java: A result was returned when none was expected. Adrian Klaver <adrian.klaver@aklaver.com>
Re: Moving from PHP to Java: A result was returned when none was expected. "David G. Johnston" <david.g.johnston@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Jan de Visser <jan@de-visser.net>
Re: Moving from PHP to Java: A result was returned when none was expected. Alexander Farber <alexander.farber@gmail.com>
Re: Moving from PHP to Java: A result was returned when none was expected. Thomas Kellerer <spam_eater@gmx.net>
Alexander Farber schrieb am 15.06.2016 um 15:56:
> Good afternoon,
> 
> at PostgreSQL 9.5.3 I have a stored function (full source code below) returning void, which I successfully call with PHP:
> 
> function skipGame($dbh, $uid, $gid) {
>         $sth = $dbh->prepare('SELECT words_skip_game(?, ?)');
>         $sth->execute(array($uid, $gid));
> }
> 
> Now I am trying to call the same function through JDBC driver 9.4.1208.jre7:
> 
>     private static final String SQL_SKIP_GAME   =
>             "SELECT words_skip_game(?, ?)";
> 
>         try (PreparedStatement st = mDatabase.prepareStatement(SQL_SKIP_GAME)) {
>             st.setInt(1, mUid);
>             st.setInt(2, gid);
>             st.executeUpdate();
>         }
> 
> and sadly get the SQLException "A result was returned when none was expected.".
> 
> Shouldn't I call executeUpdate() method here - according to the doc
> https://www.postgresql.org/docs/7.4/static/jdbc-callproc.html  ?
> 

A SELECT statement needs to be run using `executeQuery()`. 

You can also `execute()` if you want to get the update count using Statement.getUpdateCount() but I am not sure if that is actually populated through the JDBC driver for SELECT statements calling functions.

В списке pgsql-general по дате отправления
От: David G. Johnston
Дата:
От: Martín Marqués
Дата:
Сообщение: Re: PgQ and pg_dump
FAQ