Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Create a Highly Available Database Solution. Advantage Database Server can provide the availability to keep your data safe and ready for your application and users.
  #1  
Old August 29th, 2003, 12:33 PM
StevenC's Avatar
StevenC StevenC is offline
PHP & Java Error Master
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2003
Location: My Computer
Posts: 1,217 StevenC User rank is Sergeant (500 - 2000 Reputation Level)StevenC User rank is Sergeant (500 - 2000 Reputation Level)StevenC User rank is Sergeant (500 - 2000 Reputation Level)StevenC User rank is Sergeant (500 - 2000 Reputation Level)StevenC User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 1 h 15 m 14 sec
Reputation Power: 14
Problem with oracle query via Java

I'm trying to run this query in java (connected via jdbc) and I get the ORA-00936 missing expression error.
Code:
Query:
sSQL = "INSERT INTO jn_db_user_t (db_id, user_id, user_typ_cde, row_crt_dte, row_upd_dte, row_dlet_ind) \n";
sSQL = sSQL + "VALUES \n";
sSQL = sSQL + "( \n";
sSQL = sSQL + " SELECT db_id, ";
sSQL = sSQL + " ( \n";
sSQL = sSQL + " SELECT user_id \n"; 
sSQL = sSQL + " FROM prj.prj_user_t \n"; 
sSQL = sSQL + " WHERE upper(user_lname) = 'SYSDBA' \n";
sSQL = sSQL + " AND row_dlet_ind = 'N' \n";
sSQL = sSQL + " ) as user_id, \n"; 
sSQL = sSQL + " 1 as user_type_cde, \n"; 
sSQL = sSQL + " SYSDATE, \n";
sSQL = sSQL + " SYSDATE, \n"; 
sSQL = sSQL + " 'N' as row_dlet_ind \n"; 
sSQL = sSQL + " FROM db_t \n"; 
sSQL = sSQL + " WHERE upper(db_nme) " + op2[j] + " \n";
sSQL = sSQL + " AND row_status_cde <> 2\n";
sSQL = sSQL + " AND db_id IN \n";
sSQL = sSQL + " ( \n";
sSQL = sSQL + " SELECT db_id \n";
sSQL = sSQL + " FROM db_t db, db_srvr_t s, sftw_prod_vrsn_t spv, sftw_prod_t sp \n";
sSQL = sSQL + " WHERE db.db_srvr_id = s.db_srvr_id \n"; 
sSQL = sSQL + " AND s.sftw_prod_vrsn_id = spv.sftw_prod_vrsn_id \n"; 
sSQL = sSQL + " AND spv.sftw_prod_id = sp.sftw_prod_id \n"; 
sSQL = sSQL + " AND upper(sp.sftw_prod_nme) = '" + en2[j] + "' \n"; 
sSQL = sSQL + " AND db.row_status_cde <> 2 \n";
sSQL = sSQL + " ) \n";
sSQL = sSQL + " )\n";
If i strip the java coding out and run the query, this is the error I get:
Code:
 SELECT db_id, (
 *
ERROR at line 4:
ORA-00936: missing expression
Help?

Reply With Quote
  #2  
Old September 3rd, 2003, 02:24 PM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Austin, TX or the master control
Posts: 231 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 49 sec
Reputation Power: 8
you need either another field or a 'FROM' clause. you are saying:

SELECT db_id,
SELECT user_id

try

SELECT db_id, user_id

you might also want to consider reading the query in from a file, storing the query as a view, or something else. looks kinda messy how it is right now.

Reply With Quote
  #3  
Old September 3rd, 2003, 11:30 PM
crimson117 crimson117 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: New York
Posts: 19 crimson117 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to crimson117 Send a message via AIM to crimson117 Send a message via Yahoo to crimson117
Are you trying to create an Insert statement that uses the return from queries as the values, or do you intend to have the text of those queries be the values you're inserting?

Also, what are the values of op2[j] and en2[j] ? One has an equal sign before it, the other doesn't, in your code. Can you post your target query that you had and tested before you put it into a Java variable?

What you're trying to do seems strange to me; putting in select statements to get values for an insert statement. I'd do it in two separate queries, one to get the values and the other to insert the row, unless processing speed was important down to the nano-second (in which case you wouldn't be using java in the first place!:-)).

Can you use PL/SQL for this? It's great for building queries and cursors.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Problem with oracle query via Java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway