Databases Reference
In-Depth Information
return ltrim (l message ,'<li />');
end validate order adjustment;
Finally, to process the adjusted order information, you simply need to add an After Submit process
that updates DEMO ORDER ITEMS with the information in your collection. The code in Listing 10-16 shows
this simple update statement. Additionally, the last part of the process introduces the final API
references for this chapter: COLLECTION EXISTS and DELETE COLLECTION . Although it isn't necessary to
delete the collection after the user has submitted his data, the best practice is to do so. Before attempting
to delete a collection, however, you should always confirm that it exists. For these reasons, you should
generally always put the combination of COLLECTION EXISTS and DELETE COLLECTION at the end of APEX
collection processing code.
Listing 10-16. Processing Collection Data
begin
--
-- clear out original order data
--
delete from demo order items where order id = :P14 ORDER ID;
--
-- insert new order data
--
insert into demo order items (order id, product id, unit price, quantity)
select :P14 ORDER ID, c.c001 product id, c.c002 price, c.c003 quantity
from apex collections c
where c.collection name = 'ORDER ADJUSTMENTS';
--
-- clear out collection to free up resources
-- (not required, but is best practice)
--
if apex collection.collection exists('ORDER ADJUSTMENTS') then
apex collection.delete collection('ORDER ADJUSTMENTS');
end if;
end;
At this point, the user should be able to create an order, click your new “Adjust Order” button on
page 14, make adjustments to the order from page 30, and be returned to page 14 to see the adjusted
order information. To be certain, there are numerous ways to set up this same functionality—even still
using APEX collections. The approach taken above, however, allows you to explore some of the many
APEX COLLECTION API calls available to APEX developers.
Summary
Offering the ability to extend APEX's native session state management functionality into session-based
tables, APEX Collections still tend to be surprisingly underused amongst beginner and even intermediate
APEX developers. Using the techniques described in this chapter, I hope that more developers will take
advantage of this powerful functionality available within APEX applications. Although we have only
covered the most conventional uses of APEX collections here, a quick search on the Web will reveal
developers thinking outside of the proverbial box to use collections to bring new and even unforseen
power to their APEX applications.
Search WWH ::




Custom Search