[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Beginning SQL statements with a parenthesis in JDBC



The statement runs without the parenthesis, but in my case I need the parenthesis to group additional operations on either side of the UNION. 

Contrived example:
(SELECT ID FROM FOO INTERSECT SELECT ID FROM BAR) UNION (SELECT ID FROM XXX INTERSECT SELECT ID FROM YYY)

Without the parens, the results of the statement differ.


-----Original Message-----
From: george wang [mailto:george_wang@bellsouth.net]
Sent: Tuesday, February 18, 2003 4:15 PM
To: Mose, Lisle; ajug-members@ajug.org
Subject: Re: Beginning SQL statements with a parenthesis in JDBC



I would try to remove the parethesis.  I've done that and it worked.

George

----- Original Message -----
From: "Mose, Lisle" <Lisle@mediaocean.com>
To: <ajug-members@ajug.org>
Sent: Tuesday, February 18, 2003 3:43 PM
Subject: Beginning SQL statements with a parenthesis in JDBC


> Hello all,
>
> I'm running into a problem beginning a JDBC SQL statement with a
parenthesis.  I need to do something similar to the following:
> "(SELECT ...) UNION (SELECT ...)"     - the parenthesis are necessary for
grouping purposes.
>
> For the sake of testing, I tried the following and get the same error:
> "(SELECT SYSDATE FROM DUAL)"     - of course this works fine without the
parenthesis.  Also, it works fine with the parenthesis when using sqlplus
instead of JDBC.
>
>
> Here is the exception and stacktrace:
>
> Exception in thread "main" java.sql.SQLException: ORA-01009: missing
mandatory parameter
>
>         at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
>         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
>         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
>         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
>         at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
>         at
oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:242)
>         at JDBCTest.main(JDBCTest.java:17)
>
>
> I'm running against Oracle 8.1.7 using Weblogic 6.1's JDBC thin driver.
>
> Has anyone encountered this problem before?  Is there a workaround?
>
> Thanks!
> Lisle Mose
>