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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 12th, 2004, 12:05 PM
hurricane850 hurricane850 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: FLorida
Posts: 45 hurricane850 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to hurricane850 Send a message via Yahoo to hurricane850
Passing an array into a Oracle PreparedStatement

Hello,

I am trying to pass an array into a Oracle PreparedStatement, but I cannot seem to get this working. I can get this code to compile without errors but when I run the code I get:

ORA-00932: inconsistent datatypes: expected NUMBER got APAS.NUM_VARRAY

when I uncomment all the ps.execute() code I get this error:

java.sql.SQLException: ORA-00942: table or view does not exist

The code is posted below, I would appreciate any input. This is my
first time trying to pass an array to a PreparedStatement and its pretty tough. THANKS!


String sql = "SELECT PK_EMPLOYEE_ID, ROUND(AVG(xxx),2) xxx, ROUND(AVG(xxx),2) xxx " +
"FROM xxx" +
"WHERE " +
"xxx = ? " +
"xxx = ? " +
"AND xxx = ? " +
"AND xxx = ? " +
"AND PK_EMPLOYEE_ID IN (?) " +
"GROUP BY PK_EMPLOYEE_ID, xxx, xxx, xxx, xxx";

try {
crs = new CachedRowSet();
ps = (connection.getDBConnection()).prepareStatement(sql);


// ps.execute ("DROP TABLE varray_table");
// ps.execute ("DROP TYPE num_varray");

// the above drop statements will throw exceptions
// if the types and tables did not exist before
// line 47

// ps.execute ("CREATE TYPE num_varray AS VARRAY(10) OF NUMBER(12, 2)");
// ps.execute ("CREATE TABLE varray_table (col1 num_varray)");
// ps.execute ("INSERT INTO varray_table VALUES (num_varray(100, 200))");

ArrayDescriptor desc = ArrayDescriptor.createDescriptor("NUM_VARRAY", connection.getDBConnection());
ARRAY newArray = new ARRAY(desc, connection.getDBConnection(), Id);


ps.setDate(1, new java.sql.Date(startDate.getTime())); //pass the bind variable
ps.setDate(2, new java.sql.Date(endDate.getTime())); //pass the bind variable
ps.setString(3, xxx); //pass the bind variable
ps.setInt(4, xxx); //pass the bind variable
((OraclePreparedStatement)ps).setARRAY(5, newArray); //pass the bind variable
//ps.setInt(5, currentEmployeeId); //pass the bind variable

rs = ps.executeQuery();
crs.populate(rs);

ps.close();
rs.close();
connection.closeDBConnection();

Reply With Quote
  #2  
Old February 13th, 2004, 09:17 AM
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: 21 m 26 sec
Reputation Power: 8
do you have to pass an array? would passing a string not work? just trying to think of some easier solutions...before you have to start messing with native Oracle Datatypes

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Passing an array into a Oracle PreparedStatement


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 5 hosted by Hostway