APEX FAQ

From Oracle FAQ
Jump to: navigation, search
Oracle APEX (Application Express) FAQ. APEX was previously called HTML DB.

Can one print information to the screen from APEX?[edit]

Add a PL/SQL Dynamic Content type region to your page. Enter your PL/SQL code when prompted to do so. Some examples:

htp.p('Hello world');
for c1 in (select ename from emp) loop
  htp.p('Employee Name: '||c1.ename||'<br />');
end loop;

You will probably recognise the above as standard Mod_plsql code.

How do I get data in report columns to wrap?[edit]

APEX's CSS (Cascading Style Sheet) files specify that report columns should not wrap (white-space: nowrap;). This results in data being displayed on a single line and users need to scroll horizontally to see all of it.

To fix this, open your theme.css file and change the "nowrap" property to "wrap". Here is an example from theme_12's CSS file (../i/images/themes/theme_12/theme.css):

td.t12data {
       padding-top: 2px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px;
       border-collapse: collapse;
       [color=red]white-space: wrap;
       /* white-space: nowrap; */[/color]
}

Another solution would be to deleted the class="..." attribute from the <table..> tag of the report template (before rows).

How does one send E-mail from APEX?[edit]

APEX ships with a PL/SQL package called HTMLDB_MAIL that can be used to send E-mail messages.

Steps to create a PL/SQL procedure that sends E-mail:

  • Start HTMLDB and navigate to the Page Definition where you want to send e-mail from.
  • In the Page Processing area under Processes, click Create.
  • Enter your code into the Create Process Wizard:
- select On Submit - After Computations and Validations.
- From the Type list, select PL/SQL anonymous block.
FOR c1 IN (SELECT firstname,
                  email
           FROM   app_users
           WHERE  user_id = :p201_customer_id)
LOOP
  IF c1.email IS NOT NULL  THEN
    htmldb_mail.Send(p_to   => c1.cust_email,
                     p_from => c1.cust_email,
                     p_body => 'Hi ' || c1.firstname || ',' || Chr(10) || Chr(10) || 
                               'This is your notification message from HTMLDB',
                     p_subj => 'Message from HTMLDB');
  END IF;
END LOOP;

It is important to note that E-mail is not sent out immediately, but is queued until a DBMS_JOB job (wwv_flow_mail.push_queue) dequeues it and sends it out.

This job utilizes two preferences named SMTP_HOST_ADDRESS and SMTP_HOST_PORT to send mail in the queue. By default, these preferences are set to localhost and 25. To check your settings from SQL*Plus:

SQL> SELECT wwv_flow_platform.get_preference('SMTP_HOST_ADDRESS') FROM dual;
WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_HOST_ADDRESS')
-----------------------------------------------------
localhost
SQL> SELECT wwv_flow_platform.get_preference('SMTP_HOST_PORT') FROM dual;
WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_HOST_PORT')
--------------------------------------------------
25
1 row selected.