db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <tom...@gmail.com>
Subject Re: setObject(idx, bigDecimal, Types.NUMERIC); doesn't work ?
Date Tue, 03 Jan 2006 16:18:02 GMT
On 1/2/06, Bernt M. Johnsen <Bernt.Johnsen@sun.com> wrote:
> >>>>>>>>>>>> Thomas Dudziak wrote (2005-12-25 16:18:14):
> > When executing this code snippet:
> >
> >
> > Statement  stmt = conn.createStatement();
> >
> > stmt.executeUpdate("CREATE TABLE test (\n"+
> >                    "    pk INTEGER NOT NULL,\n"+
> >                    "    value NUMERIC(15,7) NOT NULL,\n"+
> >                    "    PRIMARY KEY (pk)\n"+
> >                    ")");
> > stmt.close();
> >
> > PreparedStatement pstmt = conn.prepareStatement("INSERT INTO test (pk,
> > value) VALUEs (?, ?)");
> >
> > pstmt.setInt(1, 1);>
> > pstmt.setObject(2, new BigDecimal("0.01"), Types.NUMERIC);
>
> > pstmt.execute();
> > pstmt.close();
> >
> > conn.close();
> >
> >
> > the resulting value in the database is 0e-7, not 1e-2 as I would expect.
> > When changing that to
> >
> >
> > pstmt.setBigDecimal(2, new BigDecimal("0.01"));
> >
> >
> > it works though.
> > Did I make a mistake or is this a bug ?
>
> I think you have found a bug. I experimented a bit and found that it
> works for values >= 1.0 but the result will be 0 for values < 1.0.
>
>       pstmt.setObject(2, new BigDecimal("1.0"), Types.NUMERIC);
>
> works perefectly ok while
>
>       pstmt.setObject(2, new BigDecimal("0.999999999"), Types.NUMERIC);
>
> is errouneous.

Shall I file a JIRA issue then ?

Tom

Mime
View raw message