Not able to print the value of multiple refcursor in .net.
procedure :
- CREATE OR REPLACE PROCEDURE getEmpNames
- (
- commissioned IN OUT SYS_REFCURSOR,
- salaried IN OUT SYS_REFCURSOR
- )
- IS
- BEGIN
- OPEN commissioned FOR SELECT ename FROM emp WHERE comm is NOT NULL;
- OPEN salaried FOR SELECT ename FROM emp WHERE comm is NULL;
- END;
.net code
- public void RefCursorSample(Connection con)
- {
- try
- {
- con.setAutoCommit(false);
- String commandText = "{call getEmpNames(?,?)}";
- CallableStatement stmt = con.prepareCall(commandText);
- stmt.setNull(1, Types.REF);
- stmt.registerOutParameter(1, Types.REF);
- stmt.setNull(2, Types.REF);
- stmt.registerOutParameter(2, Types.REF);
- stmt.execute();
- ResultSet commissioned = (ResultSet)stmt.getObject(1);
- System.out.println("Commissioned employees:");
- while(commissioned.next())
- {
- System.out.println(commissioned.getString(1));
- }
- ResultSet salaried = (ResultSet)stmt.getObject(2);
- System.out.println("Salaried employees:");
- while(salaried.next())
- {
- System.out.println(salaried.getString(1));
- }
- }
- catch(Exception err)
- {
- System.out.println("An error has occurred.");
- System.out.println("See full details below.");
- err.printStackTrace();
- }
- }