How to generate Success Message in Apex without using custom scripts like this video
I made a form and a button, this button inserts data into a table with identity PK using PLSQL, I want to display success message with the generated ID
The button has PLSQL like this
DECLARE
V_ID INT;
BEGIN
INSERT INTO TABLE(COL) VALUES (:VALUE) returning ID into :V_ID ;
apex_application.g_print_success_message :=
'<span style="green">'||:V_ID || 'added </span>';
END;
the row is inserted into the database but Nothing is displayed
The Video is useless to me because he/she altered an existing message, this is why apex_application.g_print_success_message
worked for the author of the video but I want to display a message like that in the first place, so how to display the message I just created.
CodePudding user response:
create a hidden page item, let's call it
P1_RETURNED_ID
button runs a process, right? That's your PL/SQL block. Change it to
insert into your_table (col) values (:P1_SOME_VALUE) returning id into :P1_RETURNED_ID;
Put this into the "Success message" property:
Added was &P1_RETURNED_ID.
(literally, ampersand (
&
) followed by item name (P1_RETURNED_ID
) followed by dot (.
)