Create a User Defined Query
This example shows how to create a user defined query to get a participant's detail attribute value and avoid associating a credit category to the measure.
The plan administrator wants to use an expression to get a participant detail attribute defined as Position and stored in ATTRIBUTE_CHAR8. But to use the expression requires associating a credit category to the performance measure. This approach causes unnecessary calculation time and many measure results if a participant has many transactions.
This is the query you're going to create:
select d.ATTRIBUTE_CHAR8
from cn_srp_participant_details_all d,
cn_period_statuses_v p
where d.participant_id = p_participant_id
and d.org_id = p.org_id
and p.period_id = p_period_id
and ( p.start_date between d.start_date and nvl(d.end_date, sysdate )
or p.end_date between d.start_date and nvl(d.end_date, sysdate ) ) ;
Here are the tasks to be done:
-
Create a value set.
-
Add the value set to a lookup code.
-
Enable inputs for the expression.
-
Create the expression.
Create a Value Set
A value set defines the actual query.
-
Create a value set that will get the value from the ATTRIBUTE_CHAR8 column for a participant:
-
In the Setup and Maintenance work area, go to the Manage Incentive Value Sets task:
-
Offering: Sales
-
Functional Area: Incentives
-
-
Click Create.
-
In the Create Value Set page, enter or select these fields:
Field
Value
Value Set Code
GetPartDetailAttr8
Description
Get Participant Details ATTRIBUTE_CHAR8 value
Module
Incentive Compensation
Validation Type
Table
Value Data Type
Character
FROM Clause
CN_SRP_PARTICIPANT_DETAILS_ALL d, CN_PERIOD_STATUSES_V p
Value Column Name
ATTRIBUTE_CHAR8
WHERE Clause
Note: This clause forms the filter the query will use. Participant ID and Period ID are the two parameters this value set expects. The numbers 1 and 2 indicate the order to pass the parameters in.d.participant_id = :1 /* NUMBER */ AND d.org_id = p.org_id AND p.period_id = :2 /* NUMBER */ AND ( p.start_date between d.start_date and nvl(d.end_date, sysdate ) OR p.end_date between d.start_date and nvl(d.end_date, sysdate ) )
-
Save and close.
-
-
Click Cancel.
Add the Value Set to a Lookup Code
You're back to the Incentives functional area in Setup and Maintenance. Add your new value set to the table value sets list you can select while you build an expression.
-
Go to the Manage Incentive Lookups task.
-
Search for the lookup type ORA_CN_USR_DEFN_EXPRSN_VLE_SET.
-
In the Lookup Codes region click New.
-
Enter the value set as a lookup code
GetPartDetailAttr8
. -
Enter the meaning Get Position.
-
Click Save and Close.
Enable Expression Inputs
Enable Participant ID and Period ID so you can choose these parameters in the expression builder.
-
Go to the Configure Tables and Columns task.
-
Use the query by example under View to search for the table CN_SRP_PER_FORM_METRICS_ALL.
-
Use Query by Example to search for the column PARTICIPANT_ID.
-
Enter the user name MSRParticipantID.
-
Select Enable for Calculation.
-
Click Save.
-
Search for the column PERIOD_ID.
-
Enter the user name MSRPeriodID
-
Select Enable for Calculation.
-
Click Save and Close.
Create the Expression
Create the expression that gets the Position attribute value from Participant Detail using the user defined query.
-
Navigate to
. -
Click Create.
-
Name the expression Get Position.
-
Create the expression:
-
Select
. -
Click Add to Expression.
-
Click the left parenthesis.
-
Select
and your performance measure (for example,Servers Attainment
), then the attribute MSRParticipantID. -
Click Add to Expression.
-
Click comma.
-
Select
and your performance measure (for example,Servers Attainment
), then the attribute MSRPeriodID. -
Click Add to Expression.
-
Click the right parenthesis.
The expression is
Position (Measure result.Servers Attainment.MSRParticipantID, Measure result.Servers Attainment.MSR Period ID)
-
Save and close.
-