Apex Collections, an example (part 2)
Here is the second part about collections, my problem could be described as:
we would like to let users add order lines to an order, update and delete them without saving anything in our database until the user confirms that the order is correct and wants to create it.
1.4 Add Member to Collection
We can now create a process that will add members to our collection and link this process to our ‘Add Row’ button.
1.5 Update Collection
Now that we can add rows to our collection, it’s time to update it. With ‘wwv_flow_collection.update_member_attribute’ we can update our collection. We must specify the collection name, seq_id, the column and its value. Create the process without any condition.
1.6 Delete Collection
Finally we can make sure that users can delete members from the collection. We will use the checkbox for this. Create a process that will be executed when the delete row button is pressed. Use ‘wwv_flow_collection.delete_members’ to delete a member from your collection. We must specify our collection name, the column where we are looking for and then the value for that column.
We will use our key value in p_c001 to delete members from our collection.
1.7 Save Results
Last but not least, we can store the members from our collection to the right table. I use a database procedure for this:
INSERT INTO order_lines (order_line_id,
WHERE collection_name = ‘ORDERS’;
(note: processes are conditional with a request so the user can browse back to page 1 without deleting his collection)