pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedstored procedure calling problem: cursor "c_get_resources" does not exist
2+ messages / 2 participants
[nested] [flat]
* stored procedure calling problem: cursor "c_get_resources" does not exist
@ 2010-02-10 14:26 Imre Fazekas <Fazekas@ygomi.com>
0 siblings, 1 reply; 2+ messages in thread
From: Imre Fazekas @ 2010-02-10 14:26 UTC (permalink / raw)
To: pgsql-jdbc
Dear All,
Let me share the following stored procedure:
CREATE OR REPLACE FUNCTION pdp.get_endpoints() RETURNS refcursor AS $$
DECLARE
c_get_resources CURSOR (ep_id text) IS
SELECT endpoint_resource.resource, endpoint_resource.sequence_index, endpoint.id, endpoint.protocol, endpoint.purpose from pdp.endpoint, pdp.endpoint_resource where endpoint.id = ep_id AND endpoint_resource.endpoint_id = endpoint.id ORDER BY endpoint_resource.sequence_index;
BEGIN
open c_get_resources( 'nform' );
RETURN c_get_resources;
END; $$ LANGUAGE 'plpgsql';
ALTER FUNCTION pdp.get_endpoints(text, text, text) OWNER TO eva;
The pgadmin accept it, i can call it using this:
SELECT pdp.get_endpoints() As Answer;
Works well.
By trying to call it using jdbc:
CallableStatement cs = db.prepareCall( "{ ? = call pdp.get_endpoints(?, ?, ?) }" );
cs.registerOutParameter(1, Types.OTHER);
cs.execute();
ResultSet rs = (ResultSet)cs.getObject(1);
I receive this:
ERROR: cursor "c_get_resources" does not exist
Does anyone an idea how can i make it work? I would really appreciate it.
Thanks in advance!
Regards,
Imre
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: stored procedure calling problem: cursor "c_get_resources" does not exist
@ 2010-02-10 20:46 Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
parent: Imre Fazekas <Fazekas@ygomi.com>
0 siblings, 0 replies; 2+ messages in thread
From: Mark Kirkwood @ 2010-02-10 20:46 UTC (permalink / raw)
To: Imre Fazekas <Fazekas@ygomi.com>; +Cc: pgsql-jdbc
Imre Fazekas wrote:
> Dear All,
>
>
> Let me share the following stored procedure:
> CREATE OR REPLACE FUNCTION pdp.get_endpoints() RETURNS refcursor AS $$
> DECLARE
> c_get_resources CURSOR (ep_id text) IS
> SELECT endpoint_resource.resource, endpoint_resource.sequence_index, endpoint.id, endpoint.protocol, endpoint.purpose from pdp.endpoint, pdp.endpoint_resource where endpoint.id = ep_id AND endpoint_resource.endpoint_id = endpoint.id ORDER BY endpoint_resource.sequence_index;
>
> BEGIN
>
> open c_get_resources( 'nform' );
>
> RETURN c_get_resources;
> END; $$ LANGUAGE 'plpgsql';
> ALTER FUNCTION pdp.get_endpoints(text, text, text) OWNER TO eva;
>
> The pgadmin accept it, i can call it using this:
> SELECT pdp.get_endpoints() As Answer;
> Works well.
>
>
> By trying to call it using jdbc:
> CallableStatement cs = db.prepareCall( "{ ? = call pdp.get_endpoints(?, ?, ?) }" );
> cs.registerOutParameter(1, Types.OTHER);
> cs.execute();
> ResultSet rs = (ResultSet)cs.getObject(1);
>
> I receive this:
> ERROR: cursor "c_get_resources" does not exist
>
>
> Does anyone an idea how can i make it work? I would really appreciate it.
>
>
> Thanks in advance!
>
> Regards,
>
> Imre
>
>
>
>
>
Try this:
db.setAutoCommit(false);
CallableStatement cs = db.prepareCall( "{ ? = call pdp.get_endpoints(?, ?, ?) }" );
cs.registerOutParameter(1, Types.OTHER);
cs.execute();
ResultSet rs = (ResultSet)cs.getObject(1);
Regards
Mark
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2010-02-10 20:46 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 14:26 stored procedure calling problem: cursor "c_get_resources" does not exist Imre Fazekas <Fazekas@ygomi.com>
2010-02-10 20:46 ` Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
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