3

When i run SQL query in oracle sql developer it is work, but in jdbc this query doesn't work and catch the java.sql.SQLSyntaxErrorException: ORA-00922: missing or invalid option. Could anyone help me ? There is my query below

CREATE GLOBAL TEMPORARY TABLE MY_TABLE (
    ID VARCHAR2(30 BYTE) PRIMARY KEY, 
    NAME VARCHAR2(20 BYTE));
INSERT INTO MY_TABLE (
    ID, NAME)
VALUES ('My_Id' , 'My_Name' );
Aram
  • 163
  • 4
  • 11
  • 2
    Try running these as two separate statements rather than as one statement. – Gordon Linoff Jun 13 '15 at 12:04
  • Show the Java code you use to execute this. Note that you can only execute **one** statement at a time. – Mark Rotteveel Jun 13 '15 at 12:05
  • This looks like a duplicate of http://stackoverflow.com/questions/18515471/can-i-execute-mysql-queries-separated-by-semicolon-in-jdbc-5 can you please check? The key issue is that you are trying to exec 2 statements in one go. – fvu Jun 13 '15 at 12:07
  • From the comment on an answer you are running something slightly different via JDBC, not what you've shown. Without the semicolons the `INSERT` keyword will be seen as part of the `CREATE`, and it is indeed invalid as part of that command. You cannot run two statements as one. – Alex Poole Jun 13 '15 at 12:41

1 Answers1

12

It is just a quick guess, because I have no oracle available to proof it, but with MyBatis (which is based on JDBC) I had this behavior with the last ;. Please try to remove it in your JDBC query.

Please create the temporary table in a first statement, then in a second statement add your data.

Barny
  • 1,685
  • 1
  • 17
  • 25
  • I remove `;` characters in jdbc query. If i doesn't remove this charcters jdbc catch the `Invalid charcters exception`. – Aram Jun 13 '15 at 12:08