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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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?

Browse pgsql-jdbc by date

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