Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-jdbc by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group