JDBC | Unable to create a volatile table using a Java client

Database
Enthusiast

JDBC | Unable to create a volatile table using a Java client


 



Hi,


when I try to create a volatile table through the execution of the following SQL instruction


 


CREATE VOLATILE TABLE EXPECTED_PROD_DIV_COUPLES AS (


    SELECT


        product_cd,


        institute_cd


    FROM


        MY_DATABASE.MY_TABLE 


    WHERE


        1=0


) WITH DATA PRIMARY INDEX (product_cd, institute_cd)


ON COMMIT PRESERVE ROWS;


 


using a Java client, the returned message is "0 rows updated." and any operation performed on the table generates an error (the volatile table is not created).


 


Here the obtained stack trace:


 


com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata Database] [TeraJDBC 14.00.00.04] [Error 3932] [SQLState 25000] Only an ET or null statement is legal after a DDL Statement. 


at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDatabaseSQLException(ErrorFactory.java:307) 


at com.teradata.jdbc.jdbc_4.statemachine.ReceiveInitSubState.action(ReceiveInitSubState.java:102) 


at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.subStateMachine(StatementReceiveState.java:298) 


at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.action(StatementReceiveState.java:179) 


at com.teradata.jdbc.jdbc_4.statemachine.StatementController.runBody(StatementController.java:120) 


at com.teradata.jdbc.jdbc_4.statemachine.StatementController.run(StatementController.java:111) 


at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:372) 


at com.teradata.jdbc.jdbc_4.TDStatement.prepareRequest(TDStatement.java:541) 


at com.teradata.jdbc.jdbc_4.TDPreparedStatement.<init>(TDPreparedStatement.java:102) 


at com.teradata.jdbc.jdk6.JDK6_SQL_PreparedStatement.<init>(JDK6_SQL_PreparedStatement.java:21) 


at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.constructPreparedStatement(JDK6_SQL_Connection.java:76) 


at com.teradata.jdbc.jdbc_4.TDSession.prepareStatement(TDSession.java:1515) 


at com.teradata.jdbc.jdbc_4.TDSession.prepareStatement(TDSession.java:1492) 


at net.sourceforge.open_teradata_viewer.actions.RunAction.createStatement(RunAction.java:250) 


at net.sourceforge.open_teradata_viewer.actions.RunAction.performThreaded(RunAction.java:84) 


at net.sourceforge.open_teradata_viewer.actions.CustomAction$1.execute(CustomAction.java:196) 


at net.sourceforge.open_teradata_viewer.ThreadedAction$3.run(ThreadedAction.java:76) 


at net.sourceforge.open_teradata_viewer.util.task.TaskExecutor.run(TaskExecutor.java:58) 


 


Open Teradata Viewer 0.09c (17/10/2011)


Windows XP 5.1 Service Pack 3 x86


Java(TM) SE Runtime Environment 1.7.0_01-b08


jdbc:teradata://<MY_SERVER>/database=MY_DATABASE,DBS_PORT=1025,CHARSET=UTF8,LOGMECH=LDAP


com.teradata.jdbc.TeraDriver


INSERT INTO EXPECTED_PROD_DIV_COUPLES (product_cd, institute_cd) VALUES ('Some text', 'Some text');


 


Thanks,


Daniel.

1 REPLY
Enthusiast

Re: JDBC | Unable to create a volatile table using a Java client

Hi,

I found a workaround to fix this error: do a COMMIT after the creation of the volatile table and before submitting any SQL instruction that acts on the volatile table.

Daniel.