Sunday, June 27, 2010

Defining LOV on Transient attribute and hide foregin key by PL/SQL helper method (ADF Jdev11g)

As mention in Andrejus Baranovskis's blog Defining LOV on reference attribute ,its quite common requirement to have reference attribute shown in LOV, and not its code. I used another way to achieve this by Transient attribute and Pl/Sql helper method and hope it is useful,
Download sample application from Here , sample use Jdev11g ps3 and HR schema
and create PL/Sql Method to get department name as follow
FUNCTION get_DepartmentName(dept NUMBER) RETURN varchar2 as
cursor crs is
select department_name from departments where department_id=dept;
begin
for i in crs loop
return i.department_name;
end loop;
return null;
end;

1. adding transient attribute and make it always updatable and mark "Mapped to Column or SQL" and "Selected in Query" check box ,then write your Pl/SQL method call in the expression section below to be selected in your view object query, to ensure that it will be retrive the department name in browsing mode


2. create LOV on your transient attribute which retrive department_name and department_Id



2 comments:

  1. Thanks
    U can write the select statment (select d.department_name from departments d where d.department_id=;
    ) in the expression section this is easy way and direct

    ReplyDelete
  2. Thanks
    you are right, may use pl function for more complex use case

    Regards
    Karim

    ReplyDelete