Calling functions with table-based-type parametars
От | Mario Splivalo |
---|---|
Тема | Calling functions with table-based-type parametars |
Дата | |
Msg-id | 1172246374.23787.25.camel@localhost.localdomain обсуждение исходный текст |
Ответы |
Re: Calling functions with table-based-type parametars
|
Список | 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 по дате отправления: