Created
September 16, 2022 00:14
-
-
Save jon-dixon/a1a0e31bb670f71a632ba4112e1b1acb to your computer and use it in GitHub Desktop.
Blog Handle IG Form and IG Regions - task_crud_apex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROCEDURE task_crud_apex IS | |
l_row_status VARCHAR2(1); | |
lr_task_rec cndemo_tasks%ROWTYPE; | |
l_new_task_id cndemo_tasks.task_id%TYPE; | |
BEGIN | |
-- Deternine if user (C)reated, (U)pdated or (D)eleted this record. | |
l_row_status := V('APEX$ROW_STATUS'); | |
-- Only need the ID for Update and Delete. | |
IF l_row_status IN ('U','D') THEN | |
-- Save TASK_ID to the PL/SQL Record. | |
lr_task_rec.task_id := V('TASK_ID'); | |
END IF; | |
IF l_row_status IN ('C','U') THEN | |
-- Populate PL/SQL record with values from Interactive Grid. | |
lr_task_rec.task_number := V('TASK_NUMBER'); | |
lr_task_rec.task_name := V('TASK_NAME'); | |
lr_task_rec.task_detail := V('TASK_DETAIL'); | |
lr_task_rec.task_owner := V('TASK_OWNER'); | |
lr_task_rec.due_date := TO_TIMESTAMP_TZ(V('DUE_DATE'), 'DD-MON-YYYY HH:MI pm'); | |
lr_task_rec.task_status := V('TASK_STATUS'); | |
END IF; | |
-- Call appropriate API to Create, Update or Delete the Task. | |
CASE l_row_status | |
WHEN 'C' THEN | |
create_task (pr_task_rec => lr_task_rec, x_task_id => l_new_task_id); | |
-- Return the new task ID (Primary key) to the field | |
-- identified as the Primary Key in the APEX IG / Form Region | |
apex_util.set_session_state ('TASK_ID', l_new_task_id); | |
WHEN 'U' THEN | |
update_task (pr_task_rec => lr_task_rec); | |
WHEN 'D' THEN | |
delete_task (p_task_id => lr_task_rec.task_id); | |
END CASE; | |
END task_crud_apex; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment