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 "Thomas Dudziak (JIRA)" <de...@db.apache.org> on 2005/12/25 15:42:32 UTC

[jira] Commented: (DERBY-785) Cannot specify default value for DECIMAL(15,15) column

    [ http://issues.apache.org/jira/browse/DERBY-785?page=comments#action_12361224 ] 

Thomas Dudziak commented on DERBY-785:
--------------------------------------

Ups, sorry, my bad. Obviously I cannot specify a default value here with a something other than 0 before the fixed point. I would mark this issue invalid if I could ;-)
Btw. for some reason this works:

CREATE TABLE test
(
    pk INTEGER NOT NULL,
    value NUMERIC(15,15) DEFAULT 1 NOT NULL,
    PRIMARY KEY (pk)
);

Also, if I try to insert something into this column, say:

        PreparedStatement pstmt = conn.prepareStatement("INSERT INTO test (pk, value) VALUEs (?, ?)");

        pstmt.setInt(1, 1);
        pstmt.setBigDecimal(2, new BigDecimal("1"));

        pstmt.execute();


then I get this exception (which is somewhat misleading):

Exception in thread "main" org.apache.derby.client.am.SqlException: BigDecimal conversion exception [converters] Overflow occurred during numeric data type conversion of "1".. See attached Throwable.
	at org.apache.derby.client.net.Request.writeBigDecimal(Unknown Source)
	at org.apache.derby.client.net.NetStatementRequest.buildFDODTA(Unknown Source)
	at org.apache.derby.client.net.NetStatementRequest.buildSQLDTAcommandData(Unknown Source)
	at org.apache.derby.client.net.NetStatementRequest.writeExecute(Unknown Source)
	at org.apache.derby.client.net.NetPreparedStatement.writeExecute_(Unknown Source)
	at org.apache.derby.client.am.PreparedStatement.writeExecute(Unknown Source)
	at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
	at org.apache.derby.client.am.PreparedStatement.executeX(Unknown Source)
	at org.apache.derby.client.am.PreparedStatement.execute(Unknown Source)
	at Main.main(Main.java:28)


> Cannot specify default value for DECIMAL(15,15) column
> ------------------------------------------------------
>
>          Key: DERBY-785
>          URL: http://issues.apache.org/jira/browse/DERBY-785
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Versions: 10.1.2.1
>  Environment: Windows XP, Java 5
>     Reporter: Thomas Dudziak

>
> Creating this table does not work:
> CREATE TABLE test
> (
>     pk INTEGER NOT NULL,
>     value DECIMAL(15,15) DEFAULT 1.0 NOT NULL,
>     PRIMARY KEY ("PK")
> );
> It does work however without the default value, e.g.
> CREATE TABLE test
> (
>     pk INTEGER NOT NULL,
>     value DECIMAL(15,15) NOT NULL,
>     PRIMARY KEY ("PK")
> );
> or when reducing the scale:
> CREATE TABLE test
> (
>     pk INTEGER NOT NULL,
>     value DECIMAL(15,14) DEFAULT 1.0 NOT NULL,
>     PRIMARY KEY ("PK")
> );
> The same holds true for a NUMERIC column.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira