Re: Error While trying to use Functions which return Resultsets

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: "Philip A(dot) Chapman" <pchapman(at)pcsw(dot)us>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Error While trying to use Functions which return Resultsets
Date: 2004-02-03 22:09:43
Message-ID: 40201C27.2090600@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Philip A. Chapman wrote:
> Everyone,
>
> I am receiving an error when I attempt the ResultSet.next() method on a
> ResultSet returned from a function. I am using PostgreSQL server and
> JDBC drivers compiled from the 7.4.1 source. I have attempted to
> emulate the first example given in the documentation (31.5.2 Obtaining
> ResultSet from a stored function). I've googled and cannot seem to find
> any mention of this error.
>
> I would appreciate any help that you may be able to provide.

While I'm not sure exactly how it applies to refcursor-returning
functions, the problem will be that all cursors are closed at the end of
a transaction unless you specify HOLD. So with autocommit on, by the
time the returned cursor is used to fetch the results, it's already been
closed.

I'm not sure how you'd specify use of HOLD in that function though.
Probably the simplest solution is to turn off autocommit unless you have
good reasons for turning it on.

> *** The Exception:
>
> Tue Feb 03 08:49:50 CST 2004
> org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>"
> does not exist

[...]

> // Turn transactions off.
> con.setAutoCommit(true);

[...]

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mofeed Shahin 2004-02-03 22:30:08 Re: metadata searching
Previous Message Oliver Jowett 2004-02-03 22:05:04 Re: metadata searching