Hello, I am new to Spring, so I have what I hope is a basic question. I've tried the search function and reading 22 pages of threads and couldn't find an answer that I understood.
I need to know the best way to get at this returned array of strings.
I am calling an Oracle stored procedure that returns a type "TABLE" (
where ACCOUNTARRAY is a table type (STRUCT).Code:PROCEDURE preAssignAccounts ( number_needed IN INTEGER, new_acct_nums OUT ACCOUNTARRAY );
My DAO looks like this:
and the inner classCode:public ReserveAccountIDBO reserveAccountIDs(ReserveAccountIDBO _req) { HashMap params = new HashMap(); params.put("@number_needed ", _req.getNumberIDs()); ReserveAccountIDs sproc = new ReserveAccountIDs(_req); HashMap result = (HashMap) sproc.execute(params); ReserveAccountIDBO _ret = (ReserveAccountIDBO) result.get("rs"); return _ret; }
and finally the result handlerCode:private class ReserveAccountIDs extends StoredProcedure { private ReserveAccountIDBO _req; public ReserveAccountIDs (ReserveAccountIDBO _req_in) { this._req = _req_in; setDataSource(getDataSource()); setFunction(false); setSql(getReserveAccountIdsStoredProc()); //input parameter declareParameter(new SqlParameter("@number_needed", Types.INTEGER)); declareParameter(new SqlReturnResultSet("rs", new ReserveIDExtractor(_req))); compile(); } }
My stored procedure generates a list of strings to return. Is this the best way to return them (using table of STRUCT)? if so, how do I load them into my business object "_req" assuming _req has methods like ".setAccountIDArray(String[] acctIDs)" or even ".addIDtoArray(String acctID)"Code:private class ReserveIDExtractor implements ResultSetExtractor { private ReserveAccountIDBO _req; public ReserveIDExtractor (ReserveAccountIDBO _req_in) { this._req = _req_in; } public Object extractData(ResultSet result) throws SQLException, DataAccessException { if (result.next()) { // what goes here? } return _req; } }
Thanks!
-david


Reply With Quote