我之前从未使用过Teradata JDBC驱动程序,所以我可能会遇到一些非常明显的事情......
基本上,我正在尝试创建一个易于查询的易失性表。
问题
也许我只能运行CREATE VOLATILE TABLE
这样的陈述......我做错了什么?
也许驱动程序版本太旧了? (目前12.00.00.110)
Java代码
PreparedStatement pstmtCreateVT = dbConn.prepareStatement(util.getQuery("CREATE_VOLATILE_TABLE_ABC"));
pstmtCreateVT.setInt(1, 7);
pstmtCreateVT.setInt(2, 11);
pstmtCreateVT.executeQuery();
Query.properties
CREATE_VOLATILE_TABLE_ABC = \
CREATE VOLATILE TABLE ABC \
AS ( SELECT DISTINCT t1.NAME \
, lookup.price \
FROM SUPERMARKET.FRUITS t1 \
INNER JOIN SUPERMARKET.PRICING lookup \
ON
lookup.price BETWEEN ? AND ? \
) \
WITH DATA NO PRIMARY INDEX \
ON COMMIT PRESERVE ROWS ;
错误
2013-11-15 09:55:19,220 DEBUG [CreatePoolingConnection.createConnection:102] url: jdbc:teradata://<<some_url_here>>/DATABASE=SUPERMARKET,ENCRYPTDATA=ON,TMODE=ANSI
2013-11-15 09:55:19,673 ERROR [BOMPartsApplicability.fetch:245] ERROR:
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata Database] [TeraJDBC 12.00.00.110] [Error 3585] [SQLState HY000] USING modifier NOT allowed with DDL.
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDatabaseSQLException(ErrorFactory.java:277)
at com.teradata.jdbc.jdbc_4.statemachine.ReceiveInitSubState.action(ReceiveInitSubState.java:102)
at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.subStateMachine(StatementReceiveState.java:285)
at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.action(StatementReceiveState.java:176)
at com.teradata.jdbc.jdbc_4.statemachine.StatementController.runBody(StatementController.java:108)
at com.teradata.jdbc.jdbc_4.statemachine.StatementController.run(StatementController.java:99)
at com.teradata.jdbc.jdbc_4.Statement.executeStatement(Statement.java:309)
at com.teradata.jdbc.jdbc_4.Statement.prepareRequest(Statement.java:467)
at com.teradata.jdbc.jdbc_4.PreparedStatement.<init>(PreparedStatement.java:53)
at com.teradata.jdbc.jdbc_4.TDSession.createPreparedStatement(TDSession.java:506)
at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalPreparedStatement.<init>(TeraLocalPreparedStatement.java:84)
at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalConnection.prepareStatement(TeraLocalConnection.java:328)
at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalConnection.prepareStatement(TeraLocalConnection.java:149)
at GroceryStore.SetupFruits.fetch(BOMPartsApplicability.java:147)
at GroceryStore.SetupFruits.main(BOMPartsApplicability.java:359)
答案 0 :(得分:4)
在我看来,如果要使用PreparedStatement
执行它们,则无法为DDL语句指定占位符(我刚刚重新创建了您尝试在DDL中创建一个带占位符的简单表的问题)。 / p>