From: Dave Cramer <pg@fastcrypt.com>
To: José Arthur Benetasso Villanova <jose.arthur@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Using PreparedStatement to call a function
Date: Wed, 14 Jun 2006 15:21:29 -0400
Message-ID: <75DA8EE3-3772-4265-B7E8-12F44110EBFC@fastcrypt.com> (raw)
In-Reply-To: <5b12ddea0606141203w5226b35al8e12acb345710b49@mail.gmail.com>
References: <5b12ddea0606141203w5226b35al8e12acb345710b49@mail.gmail.com>
Jose,
Check the archives there are a few,
Basically you have to create a class which implements the Array
interface. Most of it can be unimplemented, except for toString which
will have to return
"{string1, string2}"
and
getBaseTypeName()
which will have to return "varchar" in the case of varchar[]
Dave
On 14-Jun-06, at 3:03 PM, José Arthur Benetasso Villanova wrote:
> HI all.
>
> I have a function called:
>
> dbcmp(
> t varchar,
> p varchar[],
> c varchar[],
> n INTEGER
> ) RETURNS SETOF dbcmp_t
> ...
>
>
> Today, I call my function like this:
>
> String sql = "select * from dbcmp('" + t + "','" + p + "','" + "',"
> + n + ")";
> Statement stmt = con.createStatement(sql);
> ResultSet rs = stmt.executeQuery();
> ...
>
> I want to transform my code to use PreparedStatement like this:
>
> String sql = "select * from dbcmp(?, ?, ?, ?)";
> PreparedStatement ps = con.preparedStatement(sql);
> ps.setString(1, t);
> ps.setArray(2, p);
> ps.setArray(3, c);
> ps.setInt(4, n);
>
> But I don´t know how to create an Array object to use the set.
>
> Can anyone help me? :-)
>
> Thanks in advance.
>
> --
> José Arthur Benetasso Villanova
> ICQ 2138887
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
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: pg@fastcrypt.com, jose.arthur@gmail.com
Subject: Re: Using PreparedStatement to call a function
In-Reply-To: <75DA8EE3-3772-4265-B7E8-12F44110EBFC@fastcrypt.com>
References: <5b12ddea0606141203w5226b35al8e12acb345710b49@mail.gmail.com> <75DA8EE3-3772-4265-B7E8-12F44110EBFC@fastcrypt.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