Reputation: 2520
I am using a text field and a button in my apex application with a click event (dynamic action) for the button. After the button was pressed, data from a SQL will be inserted into the text field with this PL/SQL code:
declare
l_result varchar2(32700);
begin
for c1 in(
select ename
from emp
) loop
l_result := l_result || c1.ename || chr(10);
end loop;
:Px_TEXTAREA_ITEM := l_result;
end;
This works but now I would like to exchange the button event with a checkbox event. How to add if...else statement inside the PL/SQL query, which inserts the data if the checkbox is checked and empty the text field if it's unchecked?
Upvotes: 0
Views: 3166
Reputation: 18665
Here is sample on how to use a DA with a checkbox. This is on version 21.1 but the mechanism works for any version. Functionality: if checkbox checked then employee SCOTT gets a salary raise of 1, if checkbox unchecked then employee SCOTT gets a salary decrease of 1. This is on EMP/DEMP sample data.
P37_TOGGLE_SCOTT
of type "Checkbox". Checked value "Y", unchecked value "N"P37_TOGGLE_SCOTT
named "Raise/Lower Scott Salary". Client condition: "Item = Value", Item: P37_TOGGLE_SCOTT, Value: YBEGIN
UPDATE emp SET sal = sal + 1 WHERE ename = 'SCOTT';
END;
BEGIN
UPDATE emp SET sal = sal - 1 WHERE ename = 'SCOTT';
END;
It should be clear how to use the above sample for your business case.
Upvotes: 3