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

Bryan Pendleton commented on DERBY-6956:
----------------------------------------

Reproduces for me with the head of trunk.

The stack trace is:

{code:java}
Mon Aug 14 18:35:53 PDT 2017 Thread[main,5,main] (XID = 168), (SESSIONID = 1), 
(DATABASE = memory:test), (DRDAID = null)
, Failed Statement is: CREATE TABLE "DERBYTEST_TEMP" AS SELECT * FROM DERBYTEST 
WITH NO DATA^M
ERROR 42X71: Invalid data type 'DECIMAL(31, 6)' for column 'DECIMALCOLUMN'.
    at 
org.apache.derby.iapi.error.StandardException.newException(StandardException.java:290)
    at 
org.apache.derby.iapi.error.StandardException.newException(StandardException.java:285)
    at 
org.apache.derby.impl.sql.compile.CreateTableNode.bindStatement(CreateTableNode.java:338)
    at 
org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:401)
    at 
org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
    at 
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1114)
    at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:689)
    at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:637)
    at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:372)
    at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:533)
    at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:375)
    at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:251)
    at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
    at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
    at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
    at org.apache.derby.tools.ij.main(ij.java:59)
{code}

And line 338 of CreateTableNode.java is this "if" statement:

{code:java}
                                DataTypeDescriptor dtd = 
rc.getExpression().getTypeServices();
                                if ((dtd != null) && !dtd.isUserCreatableType())
                                {
                                        throw StandardException.newException(
                                                        
SQLState.LANG_INVALID_COLUMN_TYPE_CREATE_TABLE,
                                                        
dtd.getFullSQLTypeName(),
                                                        rc.getName());
                                }
{code}

This appears to indicate that dtd.isUserCreatableType() returned false for the 
DECIMAL(31,6) data type column.

> Create table as Select cannot copy Decimal columns
> --------------------------------------------------
>
>                 Key: DERBY-6956
>                 URL: https://issues.apache.org/jira/browse/DERBY-6956
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, SQL
>    Affects Versions: 10.13.1.1
>         Environment: Windows 7, DataGrip
>            Reporter: Murat Cengiz
>              Labels: newbie
>
> I create a test table with the following query:
> CREATE TABLE "DERBYTEST" ("STRINGCOLUMN" varchar(255), "INTEGERCOLUMN" 
> integer, "SHORTCOLUMN" varchar(255), "LONGCOLUMN" bigint, "DOUBLECOLUMN" 
> double, "FLOATCOLUMN" double, "DECIMALCOLUMN" decimal(31, 6), "BOOLEANCOLUMN" 
> smallint, "DATECOLUMN" timestamp, "DATETIMECOLUMN" timestamp, "ID" integer, 
> "LASTMODTIME" timestamp, PRIMARY KEY ("ID"))
> this query completes successfully
> I later try to copy the table with the following query:
> CREATE TABLE "DERBYTEST_TEMP" AS SELECT * FROM DERBYTEST WITH NO DATA
> This throws the following exception:
> [42X71][30000] Invalid data type 'DECIMAL(31, 6)' for column 'DECIMALCOLUMN'
> Everything works perfectly fine if I remove the decimal column.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to