• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling Oracle Stored Procedure which has parameter as CURSOR

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I would like to know,how to get more than 1 record from oracle db(by calling stored procedure) in Java.What I did is I created a Stored Procedure in oracle as :
CREATE OR REPLACE PROCEDURE getControlData(seqNum OUT seqPack.seqCur) AS
BEGIN
OPEN seqNum FOR SELECT SEQ_NO FROM CONTROL_M;
END;

CREATE OR REPLACE PACKAGE seqPack AS
TYPE seqCur IS REF CURSOR;
END seqPack;
So if I want to call this Stored Procedure from simple Java class file using JDBC,wat I need to do.I know very well that I've to use callableStatement in Java.Sql.*. But I don't know how to call a stored procedure which expects input as CURSOR.
Or if anyone knows how to get multiple rows using Storedprocedure(by creating in someother way in oracle) please let me know.It would bereally grateful.
Thanks in advance.
------------------
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

cstmt.registerOutParameter(1, Oracle.Types.Cursor).
(resultSet)cstmt.getObject(1);
 
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
also you need to include
import oracle.jdbc.driver.*;
in your java file to make it compile.
 
reply
    Bookmark Topic Watch Topic
  • New Topic