Brandon, would you please expand a little the idea of handling ref cursors through a custom type handler? Am I wrong when I say that a resultMap attribute should be added to the parameter element in the config file? Thanx for your attention, Fabio.

> -----Messaggio originale-----
> Da: Brandon Goodin (JIRA) [mailto:[EMAIL PROTECTED]
> Inviato: giovedì 7 aprile 2005 18:54
> A: Grassi Fabio
> Oggetto: [jira] Commented: (IBATIS-53) Support for oracle
> cursors as resultsets
>
>
> [
> http://issues.apache.org/jira/browse/IBATIS-53?page=comments#a
> ction_62376 ]
>
> Brandon Goodin commented on IBATIS-53:
> --------------------------------------
>
> Once we change to using execute() vs. executeQuery() (and
> executeUpdate() for consistency), it should become easy to use a
> custom type handler to deal with ref cursors.
>
> IIRC there are other ways to handle this. I seem to recall others who
> have wrapped their procs in an outer procedure that returns a result
> set. Maybe even a single proc that can wrap and execute any other
> proc.
>
>
> > Support for oracle cursors as resultsets
> > ----------------------------------------
> >
> > Key: IBATIS-53
> > URL: http://issues.apache.org/jira/browse/IBATIS-53
> > Project: iBatis for Java
> > Type: New Feature
> > Components: SQL Maps
> > Reporter: Ken Katsma
> > Priority: Minor
> > Attachments: SqlExecutor.java, SqlExecutor.java
> >
> > iBatis doesn't currently support result sets from functions
> in Oracle. A modification to SQLExecutor as detailed below
> can add the necessary support. However, it requires a
> hard-coded check for an Oracle driver. A better option would
> be to supply a factory for alternate SQLExecutor's for
> different dialects. This would allow for any future database
> specific customization as well.
> > The code change is in SQLExecutor.executeQueryProcedure
> (see comments):
> > public void executeQueryProcedure(RequestScope request,
> Connection conn, String sql, Object[] parameters,
> > int skipResults, int
> maxResults, RowHandlerCallback callback)
> > throws SQLException {
> > ErrorContext errorContext = request.getErrorContext();
> > errorContext.setActivity("executing query procedure");
> > errorContext.setObjectId(sql);
> > CallableStatement cs = null;
> > ResultSet rs = null;
> > try {
> > errorContext.setMoreInfo("Check the SQL Statement
> (preparation failed).");
> > cs = conn.prepareCall(sql);
> > ParameterMap parameterMap = request.getParameterMap();
> > ParameterMapping[] mappings =
> parameterMap.getParameterMappings();
> > errorContext.setMoreInfo("Check the output parameters
> (register output parameters failed).");
> > registerOutputParameters(cs, mappings);
> > errorContext.setMoreInfo("Check the parameters (set
> parameters failed).");
> > parameterMap.setParameters(request, cs, parameters);
> > errorContext.setMoreInfo("Check the statement (update
> procedure failed).");
> > // ****************************************
> > // Code changes below
> > // ****************************************
> > if
> (conn.getMetaData().getDatabaseProductName().equalsIgnoreCase(
> "Oracle"))
> > {
> > // If in oracle then execute instead of executeQuery
> > boolean b = cs.execute();
> > errorContext.setMoreInfo("In Oracle query mode.");
> > errorContext.setMoreInfo("Check the output
> parameters (retrieval of output parameters failed).");
> > // Get the output parameters first, instead of last
> > retrieveOutputParameters(cs, mappings, parameters);
> > // Then find the resultset and handle it
> > for (int i=0;i> > {
> > if (parameters[i] instanceof ResultSet)
> > {
> > rs = (ResultSet) parameters[i];
> > break;
> > }
> > }
> > errorContext.setMoreInfo("Check the results
> (failed to retrieve results).");
> > handleResults(request, rs, skipResults,
> maxResults, callback);
> > }
> > //****************************************
> > // Non-oracle..original code
> > else
> > {
> >
> > errorContext.setMoreInfo("In non-Oracle mode.");
> > rs = cs.executeQuery();
> > errorContext.setMoreInfo("Check the results (failed
> to retrieve results).");
> > handleResults(request, rs, skipResults, maxResults,
> callback);
> > errorContext.setMoreInfo("Check the output
> parameters (retrieval of output parameters failed).");
> > retrieveOutputParameters(cs, mappings, parameters);
> > }
> > } finally {
> > try {
> > closeResultSet(rs);
> > } finally {
> > closeStatement(cs);
> > }
> > }
> > An example mapping looks like:
> >
> > > mode="OUT"/>
> > > javaType="java.lang.String" mode="IN"/>
> >

> > > resultMap="clientResult" parameterMap="clientParameters">
> > {?= call abc.CLIENT_VIEW_PKG.client_result_list_f(?)}
> >

>
> --
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the
> administrators:
> http://issues.apache.org/jira/secure/Administrators.jspa
> -
> If you want more information on JIRA, or have a bug to report see:
> http://www.atlassian.com/software/jira
>
>
Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni contenute in questo messaggio sono riservate ed a uso esclusivo del destinatario. Qualora il messaggio in parola Le fosse pervenuto per errore, La invitiamo ad eliminarlo senza copiarlo e a non inoltrarlo a terzi, dandocene gentilmente comunicazione. Grazie.

Pursuant to Legislative Decree No. 196/2003, you are hereby informed that this message contains confidential information intended only for the use of the addressee. If you are not the addressee, and have received this message by mistake, please delete it and immediately notify us. You may not copy or disseminate this message to anyone. Thank you.

Reply via email to