IBM Support

How to use free query method when creating custom queries

Question & Answer


Question

How to use free query method when creating custom queries

Answer

This solution contains information about how the QueryHelper.freequery() is used when the query involves more than one query.

Here is a code snippet for clarification.

CUSTOMPromotionListBean promotionListBean = (CUSTOMPromotionListBean) OMWrapper.getObject(CUSTOMPromotionListBean.class);
IDsQuery q1 = QueryHelper.newWhereClause(IRdCUSTOMPromotionList.CUSTOM_PROMOTION_START_DATE, DsConstants.LE, now);
// end_date >= now
IDsQuery q2 = QueryHelper.newWhereClause(IRdCUSTOMPromotionList.CUSTOM_PROMOTION_END_DATE, DsConstants.GE, now);

IDsQuery q3 = QueryHelper.newWhereClause(IRdCUSTOMPromotionList.CUSTOM_PROMOTION_STATUS, DsConstants.EQUALS, 1);
query = QueryHelper.newWhereClause(IRdCUSTOMPromotionList.CUSTOM_CHANNEL_KEY, DsConstants.EQUALS, channelCode);
query = QueryHelper.joinWhereClauses(query, DsConstants.AND, q2);
query = QueryHelper.joinWhereClauses(query, DsConstants.AND, q1);
query = QueryHelper.joinWhereClauses(query, DsConstants.AND, q3);

promotionListBean.restore(dc, query);
QueryHelper.freeQuery(query);
QueryHelper.freeQuery(q2);
QueryHelper.freeQuery(q1);
QueryHelper.freeQuery(q3);

Here the freequery is called for each IDsQuery statement.


Q1. Does the order of calling freequery impact the operation?

A1. No, the order does not impact the operation.


Q2. Does the freequery only need to be called for the IDsQuery query?

A2. Yes, free query needs to be called ONLY for "query". It is not required for sub queries (q1, q2, q3).

[{"Product":{"code":"SS6PEW","label":"IBM Sterling Order Management"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Component":"MCS","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Historical Number

FAQ3138

Document Information

Modified date:
16 June 2018

UID

swg21518884