You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2014/06/11 15:29:02 UTC

[jira] [Commented] (DERBY-5784) Setting a parameter as NUMERIC fails to match stored value, but setting the parameter as untyped does match

    [ https://issues.apache.org/jira/browse/DERBY-5784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027743#comment-14027743 ] 

Knut Anders Hatlen commented on DERBY-5784:
-------------------------------------------

Is this perhaps the same issue that was reported in DERBY-6483 and closed as not a problem?

The repro contains this code:

{code}
        BigDecimal      decimalValue = new BigDecimal( "12.375" );

        // fails to match row
        print( "Setting NUMERIC variable..." );
        ps.setObject(1, decimalValue, Types.NUMERIC );
        printResultSet( ps.executeQuery() );
{code}

Per the JDBC API javadocs, the PreparedStatement.setObject(int, Object, int) method is supposed to assume a scale of zero. That means it should lose the fractional part. I therefore believe the above code would be equivalent to ps.setInt(1, 12), and not as one might expect ps.setDouble(1, 12.375), and Derby does the right thing by not returning a match.

> Setting a parameter as NUMERIC fails to match stored value, but setting the parameter as untyped does match
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-5784
>                 URL: https://issues.apache.org/jira/browse/DERBY-5784
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.10.1.1
>            Reporter: Rick Hillegas
>              Labels: derby_triage10_10
>         Attachments: DERBY_5784.java
>
>
> I will attach a repro. The behavior should be the same according to table B-4 in the JDBC spec. Lance Andersen reports that other databases find the row using both setObject() overloads.



--
This message was sent by Atlassian JIRA
(v6.2#6252)