From: Kris Jurka <jurka@ejurka.com>
To: mario.splivalo@mobart.hr
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Calling functions with table-based-type parametars
Date: Mon, 26 Feb 2007 10:53:18 -0700
Message-ID: <45E31E8E.9070305@ejurka.com> (raw)
In-Reply-To: <1172510852.974.2.camel@localhost.localdomain>
References: <1172246374.23787.25.camel@localhost.localdomain>
<Pine.BSO.4.64.0702231415300.13688@leary.csoft.net>
<1172506356.8206.27.camel@localhost.localdomain>
<Pine.BSO.4.64.0702261150440.21753@leary.csoft.net>
<1172510852.974.2.camel@localhost.localdomain>
Mario Splivalo wrote:
>> This is saying you need to write it with a cast from the row to the table
>> type:
>>
>> conn.prepareCall("{call f1(ROW(?, ?)::t1)}")
>
> Can't do that either. Postgres tells me that there is no type t1:
>
> 2007-02-26 18:25:19.004 CET [10324] <jura> PARSEERROR: type "t1" does
> not exist
>
> I even tried creating type _t1 wich has same member variables as table
> rows, and created function f2 wich takes _t1 as parametar, still same
> error: type "_t1" does not exsit.
>
The attached test case works fine for me without a cast. Perhaps you
can modify this to show the failure you're getting.
Kris Jurka
Attachments:RowFunc.java (text/java, 813B) download
import java.sql.*;
public class RowFunc {
public static void main(String args[]) throws Exception {
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka","jurka","");
Statement stmt = conn.createStatement();
try {
stmt.execute("DROP FUNCTION f1(t1)");
} catch (SQLException sqle) {
}
try {
stmt.execute("DROP TABLE t1");
} catch (SQLException sqle) {
}
stmt.execute("CREATE TABLE t1 (a int, b int)");
stmt.execute("CREATE FUNCTION f1(t1) RETURNS int AS 'SELECT 1' language 'SQL'");
stmt.close();
CallableStatement cs = conn.prepareCall("{? = call f1(ROW(?,?))}");
cs.registerOutParameter(1, Types.INTEGER);
cs.setInt(2,2);
cs.setInt(3,3);
cs.execute();
System.out.println(cs.getInt(1));
}
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: jurka@ejurka.com, mario.splivalo@mobart.hr
Subject: Re: Calling functions with table-based-type parametars
In-Reply-To: <45E31E8E.9070305@ejurka.com>
References: <1172246374.23787.25.camel@localhost.localdomain> <Pine.BSO.4.64.0702231415300.13688@leary.csoft.net> <1172506356.8206.27.camel@localhost.localdomain> <Pine.BSO.4.64.0702261150440.21753@leary.csoft.net> <1172510852.974.2.camel@localhost.localdomain> <45E31E8E.9070305@ejurka.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox