Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A050F9FB813 for ; Mon, 26 Feb 2007 12:12:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 28047-04 for ; Mon, 26 Feb 2007 12:12:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by postgresql.org (Postfix) with ESMTP id F37DD9FB5E6 for ; Mon, 26 Feb 2007 12:12:46 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id 7A70E186DF; Mon, 26 Feb 2007 17:12:44 +0100 (CET) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30310-03-4; Mon, 26 Feb 2007 17:12:37 +0100 (CET) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id 21DAB186DC; Mon, 26 Feb 2007 17:12:36 +0100 (CET) Subject: Re: Calling functions with table-based-type parametars From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: Kris Jurka Cc: pgsql-jdbc@postgresql.org In-Reply-To: References: <1172246374.23787.25.camel@localhost.localdomain> Content-Type: text/plain Organization: Mob-Art d.o.o. Date: Mon, 26 Feb 2007 17:12:35 +0100 Message-Id: <1172506356.8206.27.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/126 X-Sequence-Number: 16682 On Fri, 2007-02-23 at 14:20 -0500, Kris Jurka wrote: > > On Fri, 23 Feb 2007, Mario Splivalo wrote: > > > Hello again :) > > > > I have a PSQL function that accepts table-based-type as parametar: > > > > CREATE TABLE t1(c1 int4, c2 varchar); > > > > CREATE FUNCTION f1(t1) RETURNS VOID > > AS 'BEGIN RETURN END;' LANGUAGE 'plpgsql'; > > > > Now, when I call this function from another function (or from psql, for > > instance), i need to do it like this: > > > > select f1(ROW(1, 'sometext')); > > > > How do I do that from JDBC? Usualy I did it like this: > > > > callStatement = conn.getCallStatement("{call f1(?, ?)}"); > > ResultSet rs = s.executeQuery("select f1(ROW(1, 'sometext'));"); > > > > Why not conn.prepareCall("{call f1(ROW(?, ?)}") or > conn.prepareStatement("SELECT f1(ROW(?, ?))"); When I try it like above (using conn.prepaleCall), i get this: 2007-02-26 16:58:19.004 CET [9592] SELECTERROR: function f1(record) does not exist 2007-02-26 16:58:19.004 CET [9592] SELECTHINT: No function matches the given name and argument types. You may need to add explicit type casts. I know I can't but I still tried creating function with record-type parametar, postgres won't let me do so. I tried SELECT f1(ROW(1, 'one'));, that works. If I try it like this: SELECT f1(ROW(1, 'one', 'two)), postgres tells me I have to many columns, and it can't cast to t1 type. If, in Java code, i do my call like this: conn.prepareCall("{call f1(ROW(?, ?, ?)}" and set all three parametars, I still get 'function f1(record) does not exist', no complaints about missing or to many columns. I'm using pg7.4 JDBC driver with pg8.1.2, and I tought that might be the problem. But I switched to postgresql-8.1-407.jdbc3.jar, and I still get the same error. Mike