How do I get output into Java from a SELECT stored procedure in Oracle?
- by Ventrue
I'm using Java to connect to an Oracle 10 Database.
I want to create a stored procedure (don't ask why) that takes no arguments
and returns a lot of rows. Specifically, in Java I want to be able to get this
data with something like:
ResultSet rs = stmt.executeQuery("call getChildless");
where getChildless is the query:
SELECT objectid
FROM Object
WHERE objectid NOT IN (SELECT parent FROM subparts);
However, I just cannot for the life of me figure out how to get my
output from the stored procedure. I've googled it and I get
all this sample code that Oracle won't compile, presumably it's for a
previous version. Refcursors seem to come up a lot, but I'm not sure
if that's what I actually want, to use it with a ResultSet.