pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mario Splivalo <mario.splivalo@mobart.hr>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Calling functions with table-based-type parametars
Date: Mon, 26 Feb 2007 17:12:35 +0100
Message-ID: <1172506356.8206.27.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.BSO.4.64.0702231415300.13688@leary.csoft.net>
References: <1172246374.23787.25.camel@localhost.localdomain>
	<Pine.BSO.4.64.0702231415300.13688@leary.csoft.net>

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] <jura> SELECTERROR:  function
f1(record) does not exist
2007-02-26 16:58:19.004 CET [9592] <jura> 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




view thread (7+ messages)  latest in thread

Message-ID: <1172506356.8206.27.camel@localhost.localdomain>
Permalink:  ../1172506356.8206.27.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1172506356.8206.27.camel@localhost.localdomain

 · 

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: mario.splivalo@mobart.hr, books@ejurka.com
  Subject: Re: Calling functions with table-based-type parametars
  In-Reply-To: <1172506356.8206.27.camel@localhost.localdomain>
  References: <1172246374.23787.25.camel@localhost.localdomain> <Pine.BSO.4.64.0702231415300.13688@leary.csoft.net> <1172506356.8206.27.camel@localhost.localdomain>

* 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