#1054 Some comments raise SQL Exception in CREATE PACKAGE

open
nobody
5
2012-12-29
2012-10-12
David Pinho
No

I'm seeing a strange behavior (well strange for me anyway). When
creating a package in an Oracle DB:

If i execute this in SQuirreL:

CREATE OR REPLACE PACKAGE foo AS

/* comment */
c1 CONSTANT INTEGER := 1;

FUNCTION f1 (arg1 IN NUMBER, arg2 IN DATE) RETURN INTEGER;

END foo;
/

It will execute fine and create the package. But if i change the
position of the comment line:

CREATE OR REPLACE PACKAGE foo AS

c1 CONSTANT INTEGER := 1;
/* comment */

FUNCTION f1 (arg1 IN NUMBER, arg2 IN DATE) RETURN INTEGER;

END foo;
/

it will fail with the error:
Query 1 of 4, Rows read: 0, Elapsed time (seconds) - Total: 0.02, SQL
query: 0.02, Reading results: 0
Error: Invalid SQL type: sqlKind = 0
SQLState: 99999
ErrorCode: 17439
Position: 0
Error occured in:
/* comment *

If i run it in Oracle SQLPlus it will run just fine.

I'm using Oracle 10.2.0.4.0 and SQuirreL 3.4.0 (with JDK 6 and JDK7, both with ojdbc5.jar and ojdbc6.jar).

Stacktrace from SQuirreL logs:

2012-10-12 16:17:28,429 [Thread-5] ERROR net.sourceforge.squirrel_sql.client.session.MessagePanel - privateShowMessage: Exception was Warning: execution completed with warning
java.sql.SQLWarning: Warning: execution completed with warning
at oracle.jdbc.driver.DatabaseError.addSqlWarning(DatabaseError.java:945)
at oracle.jdbc.driver.DatabaseError.addSqlWarning(DatabaseError.java:993)
at oracle.jdbc.driver.DatabaseError.addSqlWarning(DatabaseError.java:1008)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:220)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.processQuery(SQLExecuterTask.java:410)
at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.run(SQLExecuterTask.java:220)
at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(TaskExecuter.java:82)
at java.lang.Thread.run(Unknown Source)

Discussion

  • David Pinho
    David Pinho
    2012-10-12

    So anyway i pulled the source and the following seems to fix it:

    ### Eclipse Workspace Patch 1.0
    #P oracle
    Index: src/main/java/net/sourceforge/squirrel_sql/plugins/oracle/tokenizer/OracleQueryTokenizer.java
    ===================================================================
    --- src/main/java/net/sourceforge/squirrel_sql/plugins/oracle/tokenizer/OracleQueryTokenizer.java (revision 6682)
    +++ src/main/java/net/sourceforge/squirrel_sql/plugins/oracle/tokenizer/OracleQueryTokenizer.java (working copy)
    @@ -239,7 +239,7 @@
    for (Iterator<String> iter = _queries.iterator(); iter.hasNext();)
    {
    String next = iter.next();
    - if (next.startsWith(sep))
    + if (next.startsWith(sep) && !next.startsWith("/*"))
    {
    tmp.add(sep);
    String[] parts = next.split(sep + "\\n+");

    Tell me what you think