From: Dario V. Fassi <software@sistemat.com.ar>
To: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Cc: Dario V. Fassi <software@sistemat.com.ar>
Subject: Re: Very strange Error in Updates
Date: Thu, 15 Jul 2004 02:40:47 -0300
Message-ID: <40F618DF.7070609@sistemat.com.ar> (raw)
In-Reply-To: <40F6172D.10301@sistemat.com.ar>
References: <40F6172D.10301@sistemat.com.ar>
Worst cases:
The receiving field is a Varchar(30) .
Sample data :
CALLE=[ENFERMERA CLEMON. B- ALTO ALBR] len=30 : Is Updated Ok.
CALLE=[ENFERMERA CLEMON. Bº ALTO ALBR] len=30 : Is NOT Updated
CALLE=[ENFERMERA CLEMON. Bº ALTO ALB] len=29 : Is Updated Ok.
Dario V. Fassi wrote:
> I found a very strange error/behavior in a PreparedStatement for a
> simple SQL Update over a VARCHAR field.
> The code is like:
>
> Statement stmt = con.createStatement();
> PreparedStatement pstIns = con.prepareStatement("update userid.t
> set calle = ? "); ResultSet rs = stmt.executeQuery( "select
> calle from userid.t2" );
> while ( rs.next() ) {
> pstIns.clearParameters();
> String x = rs.getString("CALLE");
> pstIns.setString(1, x );
> int nrows = pstIns.executeUpdate();
> System.out.println( "Filas afectadas "+ nrows );
> }
>
> When the parameter fill the full-length of receiving field and has
> any non common character, the update throw a exception like:
>
> java.sql.SQLException: ERROR: value too long for type character
> varying(30)
> at
> org.postgresql.core.v2.QueryExecutorImpl.receiveErrorMessage(QueryExecutorImpl.java:420)
>
> at
> org.postgresql.core.v2.QueryExecutorImpl.processResults(QueryExecutorImpl.java:345)
>
> at
> org.postgresql.core.v2.QueryExecutorImpl.execute(QueryExecutorImpl.java:251)
>
> at
> org.postgresql.core.v2.QueryExecutorImpl.execute(QueryExecutorImpl.java:159)
>
> at
> org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:342)
>
> at
> org.postgresql.jdbc1.AbstractJdbc1Statement.executeWithFlags(AbstractJdbc1Statement.java:290)
>
> at
> org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:245)
>
> at
> com.sistemat.app.rsmaster.reloadable.RepImportar.PrDw_Cuentas(RepImportar.java:2471)
>
> at
> com.sistemat.app.rsmaster.reloadable.RepImportar.Importar(RepImportar.java:260)
>
> at
> com.sistemat.app.rsmaster.reloadable.RepMasterImpl.Ciclo_Replicacion(RepMasterImpl.java:955)
>
> at
> com.sistemat.app.rsmaster.reloadable.RepMasterImpl.runWorker(RepMasterImpl.java:748)
>
> at
> com.sistemat.app.rsmaster.reloadable.RepMasterImpl.run(RepMasterImpl.java:427)
>
> at java.lang.Thread.run(Unknown Source)
>
> This field/value produce the Exception: CALLE=[ENFERMERA CLEMON. B§
> ALTO ALBR]
>
> If this field is changed to: CALLE=[ENFERMERA
> CLEMON. B# ALTO ALBR]
> then the update is performed without
> any problem.
>
> Although the first value can be Inserted with a prepared statement
> without problems.
>
> A have no explanation to this case , and any help will be appreciated.
>
> Dario Fassi.
>
--
Dario V. Fassi
SISTEMATICA ingenieria de software srl
<http://www.sistemat.com.ar>Ituzaingo 1628 (2000) Rosario, Santa Fe,
Argentina.
Tel / Fax: +54 (341) 485.1432 / 485.1353
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: software@sistemat.com.ar
Subject: Re: Very strange Error in Updates
In-Reply-To: <40F618DF.7070609@sistemat.com.ar>
References: <40F6172D.10301@sistemat.com.ar> <40F618DF.7070609@sistemat.com.ar>
* 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