posted 22 years ago
We are trying to call the following Oracle Function (8.1.6)
/*The package declaration*/
PACKAGE ACCOUNTSPKG IS
FUNCTION FINDRECORD
(P_ID IN accounts.id%TYPE
)
RETURN accounts%ROWTYPE;
END ACCOUNTSPKG;
Notice that the return is NOT a REF CURSOR. I have not been able to get this to work and haven't seen any examples that only return %ROWTYPE. How do you call (prepareCall("xxx")) this Function, and how do you get the resultset? [See code below]
// Begin Code
try
{
conn = DBUtil.getConnection(Constants.IPRO_DS);
// .prepareCall line throws SQL Exception:
// java.sql.SQLException: Invalid column
// type Account Info
call = conn.prepareCall (
"{ ? = call AccountsPkg.FindRecord (?)}");
call.registerOutParameter(1, OracleTypes.CURSOR);
call.setInt(2, 10);
call.execute();
ResultSet rs = (ResultSet) call.getObject(1);
while(rs != null && rs.next())
{
result += "\n AccountID: " + rs.getInt("ID")
+ "Account Type: " + rs.getString("ACCOUNT_TYPE");
}
call.close();
conn.close();
}
catch(Exception e)
{
System.out.println("AccountDAO.getAccountRS() exception: " + e);
}