Hello everyone
In this post i will show you how to perform count and sum using groovy
Note:- For this post i am using Department and Employees tables of HR Schema (oracle database 11g)
Examples
1-count employees department wise (adf.object.EmployeesView.count("EmployeeId"))
2-department wise employees salary sum (adf.object.EmployeesView.sum("Salary"))
1-count employees department wise
As we know there is relationship between Departments and Employees table (DepartmentID refer in Employees Table)
this relation in ADF is known as View Link
so by using this view link we can access EmployeesViewObjecs attributes in DepartmentViewObject
we just need accessor name to access attributes
to get accessor name we need to perform the following setps
1-open view link definition file
2-click on Edit accessors
3- copy the employees view object accessor name
4-go to Departments view object and create a new transient attribute
5-and append adf.object (it means the current object ) before accessor name and .count (count is the mehtod name) after accessor name
following is the complete groovy
adf.object.EmployeesView.count("EmployeeId")
2-department wise employees salary sum
Secondly if you want department wise salary sum
you need to perform the following steps
1-perform first 3 steps that describe above
2-create transient attribute in Department view object and set Type BigDecimal
2- write the following groovy in Expression of transient attribute
adf.object.EmployeesView.sum("Salary")
In this post i will show you how to perform count and sum using groovy
Note:- For this post i am using Department and Employees tables of HR Schema (oracle database 11g)
Examples
1-count employees department wise (adf.object.EmployeesView.count("EmployeeId"))
2-department wise employees salary sum (adf.object.EmployeesView.sum("Salary"))
1-count employees department wise
As we know there is relationship between Departments and Employees table (DepartmentID refer in Employees Table)
this relation in ADF is known as View Link
so by using this view link we can access EmployeesViewObjecs attributes in DepartmentViewObject
we just need accessor name to access attributes
to get accessor name we need to perform the following setps
1-open view link definition file
2-click on Edit accessors
3- copy the employees view object accessor name
4-go to Departments view object and create a new transient attribute
5-and append adf.object (it means the current object ) before accessor name and .count (count is the mehtod name) after accessor name
following is the complete groovy
adf.object.EmployeesView.count("EmployeeId")
2-department wise employees salary sum
Secondly if you want department wise salary sum
you need to perform the following steps
1-perform first 3 steps that describe above
2-create transient attribute in Department view object and set Type BigDecimal
2- write the following groovy in Expression of transient attribute
adf.object.EmployeesView.sum("Salary")
Please Feel Free To Ask if you Face any Difficulty
Like and share to help others
Thanks
Date 12-01-2019
Thanks for this.
ReplyDeleteIt does not seem to work on JDev 12.2.1.4.0. Would you know why?
Same Here! I've migrated my application to 12.2.1.4 and the sum function is now not working anymore.
DeleteIn case if anyone found the fix for this issue kindly share.