Databases Reference
In-Depth Information
In the Help Desk application, you want to make the home page a bit more useful by adding a quick summary of
the number of tickets an individual has open. This is applicable only if someone is logged in. So if they aren't logged
in, a simple greeting message will suffice. You can accomplish the task of adding the summary by adding a PL/SQL
region with some logic to output the appropriate message:
1.
Edit
Page 1
.
2.
Edit the
APEX Issue Tracker
region by double-clicking its name in the tree.
Currently this region is a standard HTML region, emitting exactly the HTML code you enter into it. You want to
make it dynamic, so switch it to use PL/SQL:
3.
In the
Identification
section, change
Type
to
PL/SQL (anonymous block)
, as shown
in Figure
8-35
.
Figure 8-35.
Creating a PL/SQL region
4.
Enter the following code for the
Region Source
, replacing the static HTML that was there,
and then click
Apply Changes
:
DECLARE
l_count NUMBER;
l_status_id NUMBER := get_status('OPEN');
BEGIN
IF :APP_USER != 'nobody' THEN
SELECT count(*)
INTO l_count
FROM tickets
WHERE assigned_to = :APP_USER
AND status_id = l_status_id;
htp.p('<h1>Welcome to the APEX Issue Tracking System, '
|| :APP_USER || '</h1>'
|| 'You have ' || l_count || ' Open tickets.<br />'
|| 'Select an option from the list');
ELSE
htp.p('<h1>Welcome to the APEX Issue Tracking System</h1>'
|| 'Select an option from the list');
END IF;
END;