pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: cncinfo@126.com <cncinfo@126.com>
To: pgsql-jdbc@postgresql.org
Subject: cursor "curs" already in use ?
Date: Tue, 27 Nov 2007 23:03:41 +0800
Message-ID: <1196175821.21046.10.camel@happy.letu.com> (raw)

2 function returns refcursor:

CREATE OR REPLACE FUNCTION per_getjobmind(puid bigint)
  RETURNS refcursor AS
$BODY$
declare
	curs cursor for	select workname,workold	from per_jobmind where
uid=puid;
begin
	open curs;
	return curs;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

CREATE OR REPLACE FUNCTION per_getjobmind_jobtype(puid bigint)
  RETURNS refcursor AS
$BODY$
declare
	curs cursor for	select jobtypeid from per_jobmind_jobtype where
uid=puid;
begin
	open curs;
	return curs;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

-------------------------------------------------------------------
java code:

conn.setAutoCommit(false);
cmd = conn.prepareCall("{?=call per_getjobmind(?)}");
cmd.registerOutParameter(1, Types.OTHER);
cmd.setLong(2, uid);
cmd.execute();
rs = (ResultSet) cmd.getObject(1);
if (rs.next()) {//just 1 line
	workname = rs.getString("workname");
	workold = rs.getInt("workold");

}
rs.close();
cmd.close();

cmd = conn.prepareCall("{?=call per_getjobmind_jobtype(?)}");
cmd.registerOutParameter(1, Types.OTHER);
cmd.setLong(2, uid);
cmd.execute();////////////////////////////////// error here," cursor
"curs" already in use"
rs = (ResultSet) cmd.getObject(1);
while (rs.next()) {
	jobtypeid=rs.getInt("jobtypeid");
}
rs.close();
cmd.close();
-----------------------------------------------------------------------
Can I named a refcursor in JDBC? How?





Message-ID: <1196175821.21046.10.camel@happy.letu.com>
Permalink:  ../1196175821.21046.10.camel@happy.letu.com/
Also on:    postgresql.org/message-id/1196175821.21046.10.camel@happy.letu.com

 · 

reply

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: cncinfo@126.com
  Subject: Re: cursor "curs" already in use ?
  In-Reply-To: <1196175821.21046.10.camel@happy.letu.com>
  References: <1196175821.21046.10.camel@happy.letu.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