Re: Calling functions with table-based-type parametars - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Calling functions with table-based-type parametars
Date
Msg-id Pine.BSO.4.64.0702231415300.13688@leary.csoft.net
Whole thread Raw
In response to Calling functions with table-based-type parametars  (Mario Splivalo <mario.splivalo@mobart.hr>)
Responses Re: Calling functions with table-based-type parametars
List 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


pgsql-jdbc by date:

Previous
From: Tore Halset
Date:
Subject: Re: invalid byte sequence for encoding "UTF8": 0x00
Next
From: Jonathan Halliday
Date:
Subject: bug with PGXADataSource in JNDI