Skip site navigation (1) Skip section navigation (2)

cursor "curs" already in use ?

From: "cncinfo(at)126(dot)com" <cncinfo(at)126(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: cursor "curs" already in use ?
Date: 2007-11-27 15:03:41
Message-ID: 1196175821.21046.10.camel@happy.letu.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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?



pgsql-jdbc by date

Next:From: Kris JurkaDate: 2007-11-27 19:35:07
Subject: Re: How to add data with ResultSet object?
Previous:From: Marek LewczukDate: 2007-11-27 09:02:07
Subject: Re: AbstractJdbc2Array - another patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group