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

From Mario Splivalo
Subject Calling functions with table-based-type parametars
Date
Msg-id 1172246374.23787.25.camel@localhost.localdomain
Whole thread Raw
Responses Re: Calling functions with table-based-type parametars
List pgsql-jdbc
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(?, ?)}");
callStatement.setInt(1, 1);
callStatement.setString(2, 'sometext');
callStatement.execute();
ResultSet rs = callStatement.getResultSet();

But when I do it like that I get 'function does not exists', which is
logical (my function accepts one, not two parametars).

I have found out that I can use createstatement like this:

Connection c = DriverManager.getConnection('jdbc://...');
s = c.createStatement();
ResultSet rs = s.executeQuery("select f1(ROW(1, 'sometext'));");

Now, as I understand, first snippet uses prepared statements, and second
one doesnt. Can I have prepared statements and still pass ROW as
function parametar? Or JDBC does not support that?

    Mike


pgsql-jdbc by date:

Previous
From: "Blakely, Jerel \(Mission Systems\)"
Date:
Subject: Re: Problem with jdbc connection behavior
Next
From: Tore Halset
Date:
Subject: Re: invalid byte sequence for encoding "UTF8": 0x00