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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Calling functions with table-based-type parametars



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




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group