Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A6C58632E89 for ; Wed, 10 Feb 2010 16:46:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96688-10 for ; Wed, 10 Feb 2010 20:46:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.catalyst.net.nz (bertrand.catalyst.net.nz [202.78.240.40]) by mail.postgresql.org (Postfix) with ESMTP id AFA30632AE5 for ; Wed, 10 Feb 2010 16:46:37 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 4599F32E65; Thu, 11 Feb 2010 09:46:34 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E7q0UyqHCnex; Thu, 11 Feb 2010 09:46:33 +1300 (NZDT) Received: from [IPv6:2404:130:0:1000:222:15ff:fe5c:2471] (unknown [IPv6:2404:130:0:1000:222:15ff:fe5c:2471]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id B678132B12; Thu, 11 Feb 2010 09:46:33 +1300 (NZDT) Message-ID: <4B731B29.5080702@catalyst.net.nz> Date: Thu, 11 Feb 2010 09:46:33 +1300 From: Mark Kirkwood User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Imre Fazekas CC: pgsql-jdbc@postgresql.org Subject: Re: stored procedure calling problem: cursor "c_get_resources" does not exist References: <1062D687-8DF8-4CB8-8CC9-469EEAE308BA@ygomi.com> In-Reply-To: <1062D687-8DF8-4CB8-8CC9-469EEAE308BA@ygomi.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.185 tagged_above=-10 required=5 tests=BAYES_40=-0.185 X-Spam-Level: X-Archive-Number: 201002/16 X-Sequence-Number: 20303 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