X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D5DA29FA5C8 for ; Wed, 14 Jun 2006 16:21:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 60055-02 for ; Wed, 14 Jun 2006 16:21:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id F29599FA3D7 for ; Wed, 14 Jun 2006 16:21:32 -0300 (ADT) Received: (qmail 27116 invoked from network); 14 Jun 2006 19:21:30 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 14 Jun 2006 19:21:30 -0000 In-Reply-To: <5b12ddea0606141203w5226b35al8e12acb345710b49@mail.gmail.com> References: <5b12ddea0606141203w5226b35al8e12acb345710b49@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v750) Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: <75DA8EE3-3772-4265-B7E8-12F44110EBFC@fastcrypt.com> Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: quoted-printable From: Dave Cramer Subject: Re: Using PreparedStatement to call a function Date: Wed, 14 Jun 2006 15:21:29 -0400 To: =?ISO-8859-1?Q?Jos=E9_Arthur_Benetasso_Villanova?= X-Mailer: Apple Mail (2.750) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/35 X-Sequence-Number: 15315 Jose, Check the archives there are a few, Basically you have to create a class which implements the Array =20 interface. Most of it can be unimplemented, except for toString which =20= 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=E9 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 =3D "select * from dbcmp('" + t + "','" + p + "','" + "'," =20= > + n + ")"; > Statement stmt =3D con.createStatement(sql); > ResultSet rs =3D stmt.executeQuery(); > ... > > I want to transform my code to use PreparedStatement like this: > > String sql =3D "select * from dbcmp(?, ?, ?, ?)"; > PreparedStatement ps =3D con.preparedStatement(sql); > ps.setString(1, t); > ps.setArray(2, p); > ps.setArray(3, c); > ps.setInt(4, n); > > But I don=B4t know how to create an Array object to use the set. > > Can anyone help me? :-) > > Thanks in advance. > > --=20 > Jos=E9 Arthur Benetasso Villanova > ICQ 2138887 > > ---------------------------(end of =20 > broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org >