Sitemap

Sunday, April 5, 2015

UCM: Handling SQL Queries in UCM service

In case a query have been defined in a query resource definition:

DataBinder db = new DataBinder();
db.putLocal("searchKey", searchKeyword);
db.putLocal("thName", THESAURUS_NAME);
db.putLocal("level", LEVEL);

ResultSet rs = m_workspace.createResultSet("CBIThesaurusSearch", db);
DataResultSet dataContainer = new DataResultSet();
dataContainer.copy(rs);
for (dataContainer.first(); dataContainer.isRowPresent(); dataContainer.next()) {
    System.out.println(dataContainer.getStringValueByName("THEVALUES"));
}


In case we are defining a query in the Java class itself:

String searchKeyword = m_binder.getLocal("ssUserText").toUpperCase().trim();

String maxCountRecord =
    "SELECT * FROM TABLE WHERE X_KEY = '" + key + "' AND X_ASSET_TYPE IS NOT NULL";

ResultSet resultSet = m_workspace.createResultSetSQL(maxCountRecord);
DataResultSet dataResultSet = new DataResultSet();
dataResultSet.copy(resultSet);
m_binder.addResultSet("RelatedSearchNavigation", dataResultSet);

No comments:

Post a Comment