Sitemap

Sunday, April 5, 2015

UCM: Execute a PL/SQL Procedure from a service

This is my query resource definition
 name: (ORACLE.CALLABLE)searchQuery
 queryStr: {call RELEVANCY_SEARCH_PKG.RELEVANCY_SEARCH_COUNT (?,?,?,?)}
 parameters: p_ddocname varchar
             p_search_keyword varchar
             p_asset_type varchar
             p_message out:varchar


This is the Java method:
import intradoc.common.ServiceException;
import intradoc.common.SystemUtils;

import intradoc.data.CallableResults;
import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.data.ResultSet;
import intradoc.data.ResultSetUtils;

import intradoc.server.Service;

import java.util.Properties;


public class AutoRelevancy extends Service {

    private static final String COMPONENT_DEBUG = "AutoRelevancy";

    public void calculateRelevancy() throws ServiceException, DataException {
        String searchKeyword = m_binder.getLocal("searchKeyword");

        try {
            if (m_binder.getLocal("dDocName") != null && (searchKeyword != null)) {

                String dDocName = m_binder.getLocal("dDocName");

                DataBinder db = new DataBinder();
                db.putLocal("dDocName", dDocName);
                ResultSet docInfoRS = m_workspace.createResultSet("QlatestDocInfoByName", db);

                Properties currentRowProp = ResultSetUtils.getCurrentRowProps(docInfoRS);

                final DataBinder binder = new DataBinder();

                binder.putLocal("p_ddocname", currentRowProp.getProperty("dDocName"));
                binder.putLocal("p_search_keyword", searchKeyword.toUpperCase().trim());
                binder.putLocal("p_asset_type", currentRowProp.getProperty("xasset_type"));

                CallableResults resultSql = this.m_workspace.executeCallable("searchQuery", binder);

                String v_message = resultSql.getString("p_message");
            }
        } catch (DataException d) {
            SystemUtils.trace(COMPONENT_DEBUG, "Exception" + d.getMessage());
        } catch (Exception e) {
            SystemUtils.trace(COMPONENT_DEBUG, "Exception" + e.getMessage());
        } finally {
            m_workspace.releaseConnection();
        }
    }
}

No comments:

Post a Comment