Re: Calling functions with table-based-type parametars

From: Kris Jurka <books(at)ejurka(dot)com>
To: Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Calling functions with table-based-type parametars
Date: 2007-02-23 19:20:59
Message-ID: Pine.BSO.4.64.0702231415300.13688@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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(?, ?))");

Technically the JDBC way would be to to create a class implementing
SQLData, but since the JDBC driver doesn't implement such a thing, one of
the above should work.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jonathan Halliday 2007-02-23 20:56:49 bug with PGXADataSource in JNDI
Previous Message Tore Halset 2007-02-23 17:31:38 Re: invalid byte sequence for encoding "UTF8": 0x00