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));
	}
}


