aspose file tools*
The moose likes JDBC and the fly likes how to get oracle collection ( table / record ) into java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to get oracle collection ( table / record ) into java" Watch "how to get oracle collection ( table / record ) into java" New topic
Author

how to get oracle collection ( table / record ) into java

bksella sella
Ranch Hand

Joined: Jul 31, 2003
Posts: 32
I have the below package in Oracle

CREATE OR REPLACE PACKAGE CUSTOMER_MASTER
AS
TYPE CITY_REC IS RECORD (
CITY_ID NUMBER,
CITY_NNAME VARCHAR2(2000)
);

TYPE TY_CITY_TBL IS TABLE OF CITY_REC;
END CUSTOMER_MASTER;

...and have a function which returns a collection
of CITY_REC of type TY_CITY_TBL. Is it possible to
get this collection into Java by calling the
function ?

thanks
bkSella.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Yes and No. Not directly. You have to find a tool. You can use Hibernate, but the OUT parameter has to be the first paramter. There is a tool called JPublisher, which will create Java Objects based on Oracle Types. (Personally, I do not recommend using JPublisher, because you will want to create nicer DOs rather than use the classes that JPublisher creates directly).

But I am sure other tools, like some JDO and other ORM products that will allow you to map to these Oracle types.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Sella,
As far as I know, record-types aren't supported. Use an object type instead -- and it needs to be a database type, not a type defined in a package, as in:

Don't remember the exact syntax. See the Oracle documentation for exact syntax.

Then in JDBC you can use a combination of STRUCT and ARRAY to retrieve the information. I believe you will find some examples on the OTN Web site:

http://www.oracle.com/technology

Good Luck,
Avi.
 
Don't get me started about those stupid light bulbs.
 
subject: how to get oracle collection ( table / record ) into java