• 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 Function that returns %ROWTYPE

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic