Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / January 2004

Tip: Looking for answers? Try searching our database.

No results returned with JDBC query using UNION and DUAL

Thread view: 
Andy - 26 Jan 2004 11:17 GMT
I am trying to run the following sql using

Statement s = connection.createStatement();
ResultSet result = s.executeQuery(command);
while (result.next()) { ... }

The sql returns the privileges that the user does *not* have, given a
list of privs that are required.  It returns the correct results using
Sql*plus but no results using jdbc (i.e. result.next()=false).  No
exceptions are thrown, unless I ignore the fact that resultset
returned false and try to do result.getString(1) anyway.  Then I get
java.sql.SQLException: Exhausted Resultset

I wondered if it was due to the unusual nature of the query, i.e.
using selects from dual to create a 'fake' table.

select tempPrivs.priv from (
select 'ALTER USER' priv from dual
union select 'CREATE PROCEDURE' priv from dual
union select 'CREATE SYNONYM' priv from dual
union select 'CREATE TABLE' priv from dual ) tempPrivs
where not exists (select null from user_sys_privs
                 where privilege = tempPrivs.priv);

I am using Windows XP, Oracle 8.1.7.4 database, Oracle JDBC drivers
9.2.0.4 and J2SE 1.4.1.
Anyone have any ideas?

Andy Cole.
Joe Weinstein - 26 Jan 2004 16:49 GMT
> I am trying to run the following sql using
>
[quoted text clipped - 25 lines]
>
> Andy Cole.

Is your code exactly?:

String command = "select tempPrivs.priv from ( "
               + " select 'ALTER USER' priv from dual "
               + " union select 'CREATE PROCEDURE' priv from dual "
               + " union select 'CREATE SYNONYM' priv from dual  "
               + " union select 'CREATE TABLE' priv from dual ) tempPrivs "
               + " where not exists (select null from user_sys_privs "
               + "    where privilege = tempPrivs.priv) ";

Statement s = connection.createStatement();
ResultSet result = s.executeQuery(command);
while (result.next()) { ... }

Joe Weinstein at BEA
Andy - 27 Jan 2004 11:47 GMT
Sorry everyone, it was user error.  Can't think where my brain was
yesterday but have now sorted it :-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.