Professional Documents
Culture Documents
Techniques
Email: ben.lamb@navigo.com.au
2
Introduction
Discoverer users are often unaware of advanced features Discoverer is capable of. Once
you’ve been using Discoverer for a while, you may want to extend beyond the basics to add
more complex logic, access additional information from your database or have more detailed
reports.
This whitepaper outlines some steps on how to configure Discoverer to perform more
complicated tasks.
3
1 Creating new folders in Discoverer Administrator
A folder can be either a link to an existing database table or a SQL query. They are usually
created to produce a folder based from an existing database table that does not already
exist in the EUL or to combine a number of database tables into a single folder.
Note: When creating new folders against a vendor supplied EUL, create a new Business
Area for your new folders so that if the EUL changes because of an upgrade, your work will
not be affected.
4
They are some options you can choose to do:
You can also clean the column names up by choosing to replace underscores with spaces,
remove column prefixes and capitalise the first character of the columns or all words. You
can also sort the folder and items if you like.
5
And then the folder is created
6
Example
If users only ever want to get details for employees whose job is based in Melbourne, a
folder can be made that will only contain this information.
Turn employee#
name
employee#
start_date
Into employee#
name
address location address
start_date
location
To create the folder, click on the Business Area you want to add the folder to and click
Insert->Folder->Custom. This will bring up an area where you can enter the SQL for the
custom folder.
To check the SQL query click Validate SQL and then OK and the folder is now created
This can be done both between different worksheets in the same workbook or between
worksheets in different workbooks.
• Employee List – This will contain a list of employees showing their employee id, first
name and last name
• Employee Details – this will contain employee information like email, phone number,
salary, manager and department
• Employee id
• First Name
• Last Name
8
2.2.1 Employee Details
Create a report with the following fields
• Employee id
• First Name
• Last Name
• Email
• Phone Number
• Salary
• Manager Id
• Department Id
Create a parameter for employee Id
Click New Link and fill in the link name, where you want to link to, destination workbook and
destination worksheet
9
Click on Parameters to pass a value to the parameter in the destination worksheet
10
You’ll notice that the field Employee Id has little triangles next to each employee Id
11
By clicking this link it will open up the linked workbook passing through the Employee Id as
the parameter
You can have as many links as you need attached to any field in your report creating a quick
and easy way to look at details from multiple sheets without having to open workbooks
manually and enter parameters.
12
3 Creating Custom Joins in Administrator
There are two types of joins used in Administrator:
• Inner Join
• Outer Join
Employees Positions
employee# employee#
name position#
address
Employees Positions
Employee# Name Address Employee# Position#
Inner Join
Employee# Name Address Position#
If there isn't a matching record in both tables the record will not be shown
Outer Join
Employee# Name Address Position#
Once done, the joins can be seen when the folders are expanded
15
4 Using PL/SQL functions for complex logic
Hard to create complex logic in Discoverer, you can use PL/SQL functions to overcome this
limitation.
PL/SQL function can be called either from a SQL folder in Administrator or from a calculation
in Discoverer.
• A SQL folder in Administrator would be used when all the PL/SQL needs to run can be
found in the folders it links to.
• A calculation via Discoverer would be used when the PL/SQL needs data from
Discoverer like user parameters.
If employees have multiple jobs over the course of their career and you want to find their
maximum base salary at any point in their career, this can be found through PL/SQL
referenced through a SQL custom folder.
function get_max_base_salary
( pi_employee# in varchar2,
pi_job# in varchar2 )
return number is
v_max_base_salary number;
cursor c_get_max_base_salary is
select max(o.base_salary)
from occupancy o
where o.employee# = pi_employee#
and o.job# = pi_job#;
begin
open c_get_max_base_salary;
fetch c_get_max_base_salary into v_max_base_salary;
close c_get_max_base_salary;
return v_max_base_salary;
end;
16
4.1.2 Create Custom Folder from a SQL Query
SQL queries have the ability to call the PL/SQL, so create a custom SQL folder that will get
any information you need and also call the database package. Assuming there is a folder
called OCCUPANCY that has the following fields, employee_number, job_number and
base_salary we can create the following:
Click on the business area you want to add the new folder to and click insert->folder-
>custom. This will bring up an area to create a custom folder. Next, type the following SQL
Once you click OK you will have a new folder that will return the maximum base salary for
each employee.
17
4.2 Calling functions via Discoverer
Functions that are linked to Administrator will work well in most situations, however
parameters cannot be passed to the function from Discoverer. It can be useful to pass
parameters from Discoverer if you need to base your results on a user defined parameter.
Example
If you want to find employees base salary based on a particular date, this may prove difficult
if an employee has one occupancy but their salary, which is based of their
award/classification, changes often throughout the occupancy. Discoverer can allow a
calculation to be called that will reference the function passing it parameters.
function get_max_base_salary_at_date
( pi_award in varchar2,
pi_classification in varchar2,
pi_as_at_date in date )
return number is
v_max_base_salary number;
cursor c_get_max_base_salary_at_date is
select max(a.salary)
from award_class a
where a.award = pi_award
and a.classification = pi_classification
and a.start_date = ( select max(a1.start_date)
from award_class a1
where a1.award = a.award
and a1.classification = a.classification
and a1.start_date <= pi_as_at_date
and a1.end_date >= pi_as_at_date );
begin
open c_get_max_base_salary_at_date;
fetch c_get_max_base_salary_at_date into v_max_base_salary;
close c_get_max_base_salary_at_date;
return v_max_base_salary;
end;
18
4.2.2 Register the PL/SQL Function
The PL/SQL must be registered through Administrator in order for it to be called from
Discoverer. To do this go to Tools->Register PL/SQL Functions. From here we can import
the created PL/SQL by clicking the import button and finding the created PL/SQL.
Click Validate to make sure the PL/SQL is valid and then click OK. Now you will be able to
reference the PL/SQL from Discoverer.
Note: You must reconnect to any existing Discoverer connections to be able to use the
package.
19
4.2.3 Create the calculation
Next create a calculation through Discoverer that will call the PL/SQL. The calculation will
have the following in it:
This will allow reports to be made through Discoverer that use complicated calculations
based on parameters that could not be done solely through Discoverer.
20