Sometimes we need to filter View Object data with some condition.
There are different ways of filtering data from View Object.Some of them are:-
1.) setWhereClause:-
In this method we have to use database table column to add filter.So, we have to get VO and use
"setWhereClause" same as where clause in sql.
example :-
Integer empId=4;
String fName="SCOTT";
//getting AM
EmployeesAMImpl am = (EmployeesAMImpl)resolvElDC("EmployeesAMDataControl");
// getting VO
ViewObjectImpl emp = am.getEmployee1();
//filtering data using setWhereClause
emp.setWhereClause("employee_id="+empId+" and first_name='"+fName+"'");
emp.executeQuery();
In above example employee_id and first_name is database table column and empId and fName is variable to set the value of field.
2.) getFilteredRows :-
In this method we have to use VO column to add filter.So, we have to get VO and use
"getFilteredRows" .This method is use to filter for only one column. Method getFilteredRows return type is Row[].
example:-
Integer empId=4;
//getting AM
EmployeesAMImpl am = (EmployeesAMImpl)resolvElDC("EmployeesAMDataControl");
// getting VO
ViewObjectImpl emp = am.getEmployee1();
//filtering data using getFilteredRows. As this method returns Row[] type ,so we can use thats row //for our purpose.
Row[] Emprow= emp.getFilteredRows("EmployeeId", empId);
In above example EmployeeId is VO column name and empId is variable to set the value of field.
3.) RowQualifier:-
In this method we have to use VO column to add filter.So, we have to get VO and use "setWhereClause" method of RowQualifier and "getFilteredRows" method of VO for filtering .This method is use to filter on the basis of 1 or more columns.Method setWhereClause is used to filter data and method getFilteredRows return type is Row[] after filtering.
example:-
Integer empId=4; String fName="SCOTT";
//getting AM
EmployeesAMImpl am = (EmployeesAMImpl)resolvElDC("EmployeesAMDataControl");
// getting VO
ViewObjectImpl emp = am.getEmployee1();
// creating RowQualifier
RowQualifier rowQualifier = new RowQualifier(emp);
// filtering data using method setWhereClause
rowQualifier.setWhereClause("EmployeeId="+empId+" AND FirstName="+fName);
// use method getFilteredRows to return Row[] type after filter.
Row[] filteredRows = emp.getFilteredRows(rowQualifier);
In above example EmployeeId and FirstName are VO column name and empId and fName are variable to set the value of field.
Note:- setWhereClause is use to filter data using database column.
getFilteredRows is use to filter data using VO column name but only one column is use to filtering of data using this method.
RowQualifier is use to filter data using VO column name but one or more than one column is use to filtering of data using this method.We have to use both use "setWhereClause" method of RowQualifier and "getFilteredRows" method of VO for your purpose.
There are different ways of filtering data from View Object.Some of them are:-
1.) setWhereClause:-
In this method we have to use database table column to add filter.So, we have to get VO and use
"setWhereClause" same as where clause in sql.
example :-
Integer empId=4;
String fName="SCOTT";
//getting AM
EmployeesAMImpl am = (EmployeesAMImpl)resolvElDC("EmployeesAMDataControl");
// getting VO
ViewObjectImpl emp = am.getEmployee1();
//filtering data using setWhereClause
emp.setWhereClause("employee_id="+empId+" and first_name='"+fName+"'");
emp.executeQuery();
In above example employee_id and first_name is database table column and empId and fName is variable to set the value of field.
2.) getFilteredRows :-
In this method we have to use VO column to add filter.So, we have to get VO and use
"getFilteredRows" .This method is use to filter for only one column. Method getFilteredRows return type is Row[].
example:-
Integer empId=4;
//getting AM
EmployeesAMImpl am = (EmployeesAMImpl)resolvElDC("EmployeesAMDataControl");
// getting VO
ViewObjectImpl emp = am.getEmployee1();
//filtering data using getFilteredRows. As this method returns Row[] type ,so we can use thats row //for our purpose.
Row[] Emprow= emp.getFilteredRows("EmployeeId", empId);
In above example EmployeeId is VO column name and empId is variable to set the value of field.
3.) RowQualifier:-
In this method we have to use VO column to add filter.So, we have to get VO and use "setWhereClause" method of RowQualifier and "getFilteredRows" method of VO for filtering .This method is use to filter on the basis of 1 or more columns.Method setWhereClause is used to filter data and method getFilteredRows return type is Row[] after filtering.
example:-
Integer empId=4; String fName="SCOTT";
//getting AM
EmployeesAMImpl am = (EmployeesAMImpl)resolvElDC("EmployeesAMDataControl");
// getting VO
ViewObjectImpl emp = am.getEmployee1();
// creating RowQualifier
RowQualifier rowQualifier = new RowQualifier(emp);
// filtering data using method setWhereClause
rowQualifier.setWhereClause("EmployeeId="+empId+" AND FirstName="+fName);
// use method getFilteredRows to return Row[] type after filter.
Row[] filteredRows = emp.getFilteredRows(rowQualifier);
In above example EmployeeId and FirstName are VO column name and empId and fName are variable to set the value of field.
Note:- setWhereClause is use to filter data using database column.
getFilteredRows is use to filter data using VO column name but only one column is use to filtering of data using this method.
RowQualifier is use to filter data using VO column name but one or more than one column is use to filtering of data using this method.We have to use both use "setWhereClause" method of RowQualifier and "getFilteredRows" method of VO for your purpose.
No comments:
Post a Comment