From: Leo Martin Orfei <orfeileo@yahoo.com>
To: pgsql-general@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: problems returning a resultset from a function
Date: Sat, 4 Sep 2004 09:07:47 -0700 (PDT)
Message-ID: <20040904160747.66889.qmail@web51806.mail.yahoo.com> (raw)
hi.
I have a problem with postgres functions.
I need return a resultset from a postgres function and
browse the resultset in a java app.
I try with this simple function:
create function test() returns catalog.refcursor as'
declare aux refcursor;
BEGIN
OPEN aux FOR SELECT name, address FROM table;
RETURN aux;
END;
'LANGUAGE 'plpgsql';
and the java
CallableStatement cs = null;
ResultSet rs = null;
cs = con.prepareCall("{ ? = call test()}");
cs.registerOutParameter(1, java.sql.Types.OTHER);
rs = cs.executeQuery();
rs.next();
System.out.println("name: " +rs.getString(1));
but throws te following error:
cursor "<unnamed portal 1>" does not exist
I try this too:
Statement s = null;
rs = s.executeQuery("select test()");
rs.next();
System.out.println("name: " +rs.getString(1));
and don't throws an error, but show me the following
result:
name: <unnamed portal 1>
anybody can help me with this?
thnx;
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: orfeileo@yahoo.com, pgsql-general@postgresql.org
Subject: Re: problems returning a resultset from a function
In-Reply-To: <20040904160747.66889.qmail@web51806.mail.yahoo.com>
References: <20040904160747.66889.qmail@web51806.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox