Reusable Code – How to check existing record

*It checks for existing record based on provided parameter. Check ViewObject.estimatedRowCount>0 for results
*@Param – ViewObject Name to be checked
*@Param – where clause needs to be executed
*@return – returns updated viewObject.

public ViewObjectImpl checkForExistingRecord(String viewObjectName,
Map<String, Number> params) {

Row[] resultRows = null;
ViewObjectImpl viewObject =

if (params != null) {
Iterator paramsIter = params.keySet().iterator();
while (paramsIter.hasNext()) {
String key = (String);
viewObject.setNamedWhereClauseParam(key, params.get(key));
System.out.println(“Query after modification : ” + viewObject.getQuery());
System.out.println(“Where clause after modification : ” + viewObject.getNamedWhereClauseParam(key));
resultRows = viewObject.getAllRowsInRange();

return viewObject;

*This method is called from previous method

public ApplicationModule getAppModule() {
DCBindingContainer bindings = (DCBindingContainer)getBindings();
ApplicationModule appModule =
return appModule;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s