pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: Imre Fazekas <Fazekas@ygomi.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: stored procedure calling problem: cursor "c_get_resources" does not exist
Date: Thu, 11 Feb 2010 09:46:33 +1300
Message-ID: <4B731B29.5080702@catalyst.net.nz> (raw)
In-Reply-To: <1062D687-8DF8-4CB8-8CC9-469EEAE308BA@ygomi.com>
References: <1062D687-8DF8-4CB8-8CC9-469EEAE308BA@ygomi.com>

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



view thread (2+ messages)

Message-ID: <4B731B29.5080702@catalyst.net.nz>
Permalink:  ../4B731B29.5080702@catalyst.net.nz/
Also on:    postgresql.org/message-id/4B731B29.5080702@catalyst.net.nz

 · 

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: mark.kirkwood@catalyst.net.nz, Fazekas@ygomi.com
  Subject: Re: stored procedure calling problem: cursor "c_get_resources" does not exist
  In-Reply-To: <4B731B29.5080702@catalyst.net.nz>
  References: <1062D687-8DF8-4CB8-8CC9-469EEAE308BA@ygomi.com> <4B731B29.5080702@catalyst.net.nz>

* 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