Skip to content

Instantly share code, notes, and snippets.

@jon-dixon
Last active February 8, 2023 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jon-dixon/cc54ad39d4e922c44e74da7be04bdc17 to your computer and use it in GitHub Desktop.
Save jon-dixon/cc54ad39d4e922c44e74da7be04bdc17 to your computer and use it in GitHub Desktop.
Working with Lists APEX_STRING.PUSH
DECLARE
CURSOR cr_tasks IS
SELECT task_id
, task_status
FROM cndemo_tasks;
lt_archived_task_ids apex_t_number;
BEGIN
-- Loop through all tasks.
FOR task_rec IN cr_tasks LOOP
IF task_rec.task_status = 'ARCHIVE' THEN
-- Do some processing.
-- Add the task ID to the array.
-- apex_string.push always appends the value to the array.
apex_string.push
(p_table => lt_archived_task_ids,
p_value => task_rec.task_id);
END IF;
END LOOP;
-- Show the Task IDs in the array using apex_string.join.
dbms_output.put_line('Array Contents: ' || apex_string.join(lt_archived_task_ids,':'));
-- Delete Task IDs that has a status of ARCHIVE
DELETE FROM cndemo_tasks
WHERE task_id MEMBER OF lt_archived_task_ids;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment