Convert PL/SQL to javascript
Hi all,
I'm having some performance issues with a dynamic action. Will name this action DA_UPDATE_OPM
This action should run unconditionally on the change of almost any item on a region and results in the setting of just 1 field.
Since all items are related with other dynamic actions ( specific to this application ) the dynamic action DA_UPDATE_OPM fires many times when you update 1 field on the form ( since other fields are update due to this value change and due to that the DA_UPDATE_OPM can fire up to 30 times as a result of 1 value change.
I've tried to recode this PL/SQL block which is fired but if I don't want to lose functionality I don't see any other way out as to do it like this.
Because it's PL/SQL I have to post all the items being used in this block to the database and due to this being done 30 times ( for example ) the field update is really slow.
So I think my only way out is to recode this to javascript ( which I don't know ) so I can do everything client side.
The Pl/SQL block looks something like this, orig is much longer but it's just more of the same code as below :
declare
opmerking_nr number;
begin
opmerking_nr := '';
if :P2_MRES_SAUREUS = 59 then opmerking_nr := 2; else opmerking_nr := 7; end if;
return opmerking_nr;
end;
Can anybody help me recode this to javascript which I can use in APEX 4.02 ? I see different kind of examples when I google, but in the end I'm not sure what the best solution for APEX 4 would be.
<<edit>>
after some tests i've come to this point, which does not work but also doesn't give any errors, the if statement always returns true so that's probably the error, but I'm not sure why. The setting of the value part works fine ( only the condition when is the problem ).
if ( $x('P2_MRES_SAUREUS').value = 59 )
{
$x('P2_OPMERKING_NR').value = 2;
}
else
{
$x('P2_OPMERKING_NR').value = 7;
}
Cheers
Bas
Edited by: user3338841 on 23-apr-2011 5:28