Hello Sir,
I have a general question.
I would like to create a functiion to insert a value in a table depending on the action of the logged in user.
This means when the user clicks on accept, then an entry should be made in the column like 'ACCEPTED'. But when the user clicks on the button denied, then another entry should be made like 'DENIED' in the column.
I want then create processes in the page which call the different functions and are executed when a button is clicked. So for example for the button submit I call the function which makes an insert 'ACCEPTED' in the column of the table. For the button denied I call another function, which inserts another entry in the table etc.
My general question is:
- how can different insertions be made in the table depending on the button actions?
- is the presented approach useful for such an issue?
Vinish Kapoor
Your approach is fine. But you can use the single function for both the buttons. You can pass the parameter to the function. Below is an example:
You can now create two processes in Apex, each one will be executed on a particular button (accepted/denied). Below is the process code example:
Ana
Thank you for this answer!!
I only slightly changed the function call in processeses to
DECLARE
x boolean;
BEGIN
x:=insert_acc_den('ACCEPTED');
END;
as I did get an error here that the function is not a stored procedure.
Vinish Kapoor
Correct, I missed it 😀
Ana
One thing I noticed is that the entry is made separately in another row of the table and not together with the submitted data after a submit.
So in other words I automatically get two entries.
1st entry: the submitted data
2nd entry: the entry by the action of a button ('ACCEPTED').
However, I would like both entries to be entered in the same row. Do I have to change the function a little for this?
Vinish Kapoor
You can make the process to run on click of the specific button. You will find the setting in process properties > server-side condition > when button pressed.
Also, you can modify the function to run first update and if update fails then insert. Below is an example:
Ana
Thank you for the fast reply!
I now changed the function like you sugessted, I then called this function with the code shown below, my key value is a page item from another page.Unfortunately I still get 2 entries in the table.
DECLARE x boolean; BEGIN x:= insert_acc_den ('REQUESTED',:P3_FPID); END;
Vinish Kapoor
Are you doing double click on the Submit button? You should click once.
Try creating submit button as shown in the following tutorial:
https://www.foxinfotech.in/2020/08/oracle-apex-dynamic-action-submit-page-example.html
Ana
So I created the dynamic action as described in the tutorial (Thanks for that!)
and this is the process where I call the function to update the column in the table.
It is excuted when the button submit is clicked:
I still get two entries, I don't know what I am missing here:/
Ana
I solved the by changing the function.
Thank you very much for your help!!