A CallableStatement was executed with nothing returned
<p>I have a Java exception when calling a function that returns nothing:</p>

<pre><code>org.postgresql.util.PSQLException: A CallableStatement was executed with nothing returned.
</code></pre>

<p>The Java code is similar to this:</p>

<pre><code>// Procedure call.
CallableStatement proc = con.prepareCall("{ ? = call doquery ( ? ) }");
proc.registerOutParameter(1, Types.Other);
proc.setInt(2, 33434);
proc.execute();
ResultSet results = (ResultSet) proc.getObject(1);
while (results.next()) {
  // do something with the results...
}
results.close();
proc.close();
</code></pre>

<p>The query is very simple:</p>

<pre><code>select * from table where idTable = 33434;
</code></pre>

<p>The query does not return any value because what I'm looking for in postgresql DB does not exist. A sql query is like that, not always we get something in return.</p>

<p>How do you deal with this situations?</p>

<p>PS.- The Postgresql function:</p>

<pre><code>CREATE OR REPLACE FUNCTION doquery(_idTable bigint)
  RETURNS TABLE(idTable bigint, name varchar) AS
$BODY$
DECLARE
    searchsql text := '';
BEGIN
    searchsql := 'SELECT * FROM table
            WHERE idTable = ' || _idTable;

    RETURN QUERY EXECUTE searchsql;
END
$BODY$
  LANGUAGE plpgsql;
</code></pre>