Thursday, August 5, 2010

Getting multiple out parameters from oracle procedures

By using "DataReadQuery " when calling oracle stored procedure you can get values for multiple out parameters


here is the code snippet one i found in net when searching for this concept


 JpaEntityManager jpaEntityManager = JpaHelper.getEntityManager(em);  
 Session session = jpaEntityManager.getActiveSession();  
 StoredProcedureCall spc = new StoredProcedureCall();  
 spc.setProcedureName(“two_args_out”);  
 spc.addNamedArgument(“x”);  
 spc.addNamedOutputArgument(“y”);  
 spc.addNamedOutputArgument(“z”);  
 DataReadQuery query = new DataReadQuery();  
 query.setCall(spc);  
 query.addArgument(“x”);  
 List args = new ArrayList();  
 args.add(“Wouter”);  
 List results = (List) session.executeQuery(query, args);  
 DatabaseRecord record = (DatabaseRecord)results.get(0);  
 String y = (String) record.get(“y”);  
 String z = (String) record.get(“z”);  

Before this i have used ValueReadQuery to get result set from the procedure.but it doesn't help with multiple out parameters ,it returns only one.

No comments:

Post a Comment