Does anybody know how to create a compute field based on other input fields and data retrieved from the database in the same page ?
I use an interactive form and report which has 2 input fields, 1 drop-down list containing identifiants and a kind of total field which has to be calculated from the 2 first input fields, 1 value retrieved from the database by the identifiant seleted that i may put in a hidden field. On form submit (click on the create button), the value calculated in this compute field has to be inserted into database as any other input field.
I've tried many things : button , process, computations after regions and so on but nothing works. I wonder if i can put some pl/sql or expression in the default value of the compute field ?
As i'm new in apex, can somebody tell me how do these objects work together ? how to refer to a field in the form with an 'apex expression' ?
Thks a lot
I don't know what you mean by computation did not work. You need to create a Page Computation which fires after Page Submit and that will have computed value and should use SQL process to update the field with computed column value.
There are many ways to achieve this but the above solution is straight forward and should work.
but by this way, i can only know the total after insert/update in the database, right ?
what should i do if i'd like to know the value of the compute field as soon as i leave the focus of the input fields or on click on a button called "compute CTP" for example ?
if there's no way to do that, your solution will be OK too.
Edited by: user469717 on Apr 22, 2013 4:55 AM
I've tried 2 solutions. The first one, with calculations performed by trigger, works well but i can't see the total before inserting into DB.
The second is what i prefer but impossible to get it work.
So if someone has an idea, please help in my pdetail_modele page_
- 2 input fields P28_X and P28_Y
- 1 compute field P28_CTP
- a button "compute CTP" which has to display, for example, the sum of P28_X and P28_Y in the P28_CTP field.
Here is what i did
- process (before regions) create_mod_collection:
if apex_collection.collection_exists(p_collection_name=>'MODELE') = false then
for x in (select n001, n002 from apex_collections where collection_name='MODELE')
:P28_X := x.n001;
:P28_Y := x.n002;
- P28_X and P28_Y : nothing in source field
- P28_CTP source value or expression : select nvl(:P28_X,0) + nvl(:P28_Y,0) from dual;
- Button Compute_CTP action : redirect to page in this application with p_detail_modele in page field.
- process (after regions) add_modele_collection :
apex_collection.add_member(p_collection_name=> 'MODELE', p_n001=>:P28_X, p_n002=>:P28_Y);
Edited by: user469717 on Apr 23, 2013 11:33 AM