Far
Far

Reputation: 439

Oracle APEX 5 Dynamic Action upon page load event does not work. What am i doing wrong?

The program basically aims at retrieving some fields of a record and processing and displaying that on a textbox of static content region in apex 5

My database: LCD_MONItOR table

enter image description here

Interface :

enter image description here

PLSQL code that is supposed to execute on page load event.

   Declare 

   lcd_id   LCD_Monitor.LCD__NO%TYPE;
   tag        LCD_Monitor.ASSET_TAG%TYPE;
   pp      LCD_Monitor.PURCHASE_PRICE%TYPE;
   sal      LCD_Monitor.SALVAGE%TYPE;
   ls       LCD_Monitor.LIFE_SPAN%TYPE;
   accm  LCD_Monitor.ACCUMULATED_DEP%TYPE;
   netbook Number;
   currDep Number;
   Begin
   select LCD__NO, ASSET_TAG, PURCHASE_PRICE,SALVAGE, LIFE_SPAN,
   ACCUMULATED_DEP into lcd_id, tag, pp, sal, ls, accm from LCD_MONITOR 
   where LCD__No='40';

   :LCD_NO:=lcd_id;
   :CURR_DEP:= (pp-sal)*(1/ls);
   :TOT_DEP:= (pp-sal)*(1/ls)+accm;
   :NBV:=pp-(pp-sal)*(1/ls)+accm;

   End;

PS: I have returned the values to the textboxes in 'Affected Elements' Section in the properties.

enter image description here

But when the page is loaded, no values appear in the textboxes. Any help would be appreciated.

Upvotes: 1

Views: 6417

Answers (2)

Far
Far

Reputation: 439

Instead of directly assigning a calculated value to the textfields items, I assigned them to a variable first then assigned variables to the items i.e

Before

   :CURR_DEP:= (pp-sal)*(1/ls);
   :TOT_DEP:= (pp-sal)*(1/ls)+accm;
   :NBV:=pp-(pp-sal)*(1/ls)+accm;

Corrected

    currDep:= (pp-sal)*(1/ls);
    :CURR_DEP:= currDep;
    tot:= (pp-sal)*(1/ls)+accm;
    :TOT_DEP:=tot;
    netbook:=pp-((pp-sal)*(1/ls)+accm);
    :NBV:=netbook;

Upvotes: 0

Dmitriy
Dmitriy

Reputation: 5565

I'm not sure if I understood correctly what exactly are you doing. If you need just fill items with data, create a before header process (in Page Designer mode, it is in Pre-rendering -> Before Header. Write your code there, it should be enough.

If you want to do it in Dynamic Action (I wouldn't recommend this way), you need to create a Dynamic Action with Event - Page Load, which will contain a True Action with properties: Action - Execute PL/SQL Code, PL/SQL Code - your code and Items to Return - LCD_NO,CURR_DEP,TOT_DEP,NBV
But make sure your items really have such names, because by default APEX creates items with names like P10_LCD_NO, where 10 (for example) is a number of the page.

Upvotes: 2

Related Questions