Friday 21 September 2012

Creating And Displaying a Page Items Value Using Dynamic Action

                                                In this topic, you create a dynamic action that shows the Sales Bonus when the Sales Amount is not null or changes.
    Right-click Dynamic Actions and select Create.
    Select Advanced for type of dynamic action and click Next.
    Enter Calculate Bonus for Name and click Next.
    Make sure the following fields are set: Event = Change, Selection Type = Item(s), Item(s) = P2_SALES_AMOUNT, Conditon = greater than and Value = 0. Then click Next.
    Select Execute PL/SQL Code for Action and enter the following for PL/SQL Code (or copy the code from /home/oracle/Desktop/solutions/apexp2_lab/dynaction01.txt)
    declare
      l_commission number;
    begin
      SELECT commission_pct INTO l_commission
      FROM employees
      WHERE employee_id = :P2_EMPLOYEE_ID;
    
      :P2_BONUS := :P2_SALES_AMOUNT*l_commission;
    end;
    Enter P2_EMPLOYEE_ID,P2_SALES_AMOUNT for Page Items to Submit and enter P2_BONUS for Page Items to Return and click Next.
    You don't want to create a false action. Click Next.
    Click Create.
    You want to set the default for P2_SALES_AMOUNT to 0, Double-click P2_SALES_AMOUNT Page Item.
    Click the Default subtab.
    Enter 0 for default value and click Apply Changes.
    Click Run.
    Enter 2000 for Sales Amount and press enter. Notice that the value of Sales Bonus changes to 500 because the Commission Pct is .25. Click the Edit Page button in the Developer Toolbar. In the next topic, you examine how a plug-in works.

No comments:

Post a Comment