Nov 09 2011

Customize/Personalize Oracle APEX Workspace Environment

Category: 11g,APEX,Browser,Tool,URLittichai @ 4:06 pm

When you have multiple Oracle APEX environments, e.g., development, test, UAT and production, and for multiple groups, one of the confusing things is that sometimes developers are lost on which environment they’re working on. Most of technically proficient developers can make a distinction easily from the URLs they’re currently using. However, most of less technically proficient (e.g., business users) sometimes cannot.

A quick and simple solution here is to make a visual distinction on the APEX workspace pages especially on the logo area. Instead of using plain vanilla logo images, they are replaced with more distinct and informative images.

This is the default APEX workspace logon page.

Default Workspace Logon Image

This is a sample of the personalized workspace logon page with a company logo and it is showing that this is the development environment.

Customized APEX workspace logon page

This is the main workspace page after logon showing the default logo image.

Default Workspace Page

You can change it to be like this.

Customized APEX workspace development page

With just this minor change, our users feel more comfortable knowing that they’re working the right environment.

How to change it?

With a quick investigation, you can easily find the paths of those image files as follows:

Workspace logon page:

Image path: /i/apex/builder/apex-logo-white.gif
Image size: 300px x 30px
Transparent background

Image path:/i/apex/builder/apex-db-apps.png
Image size: 240px x 200px
Transparent background

Workspace main page after logon:
Image path: /i/htmldb/apex_logo.gif
Image size: 300px x 30px
White background

  • Use Photoshop or any image editing tools to recreate those image files.
  • Copy and replace those image files on the web server. Please make the backup of those files before replacing them.

Note that this approach will NOT work if you’re using a shared web server for multiple APEX database environments because they’re using the same image files.

Update: Using ApexLib script in the login message (under Manage Instance) as mentioned by Peter in the comment section is another solution for customization. I like this approach as not only you can customize the logo, but you can also change the description text on the workspace logon page. In addition, since the change is on the APEX instance itself, it can definitely be used on a shared web server.


Sep 21 2011

Oracle APEX (Application Express) Built-in LDAP Test Tool Stand-alone Application

Category: APEX,Tool,URLittichai @ 6:56 pm

Oracle APEX provides multiple ways for authentication. The most commonly used one is the LDAP authentication. Configuring it is very straight-forward in most cases – just providing the LDAP host, port, whether or not to use SSL, and finally the DN string. See here and here for posts about APEX LDAP configuration.

Sometime you want to test the LDAP configuration before deploying it. You can either use the 3rd-party tools to validate the configurations, or create an APEX application to test the logon, or use the built-in LDAP test tool in APEX.

The built-in APEX LDAP test tool can be launched when the authentication is being configured as seen below.

LDAP Test Tool

It will pop-up a new window as shown below.

LDAP Test Tool Pop-up Screen

By accident, I found out that you can even launch the APEX LDAP Test Tool as the stand-alone application using Application ID 4000 and Page Number 3890.

For example,

http://localhost:8888/apex/f?p=4000:3890

It will obviously prompt you to log on to the workspace first, then the LDAP test tool will just show just like an application, not the pop-up window.

Additional resources:


Feb 21 2011

Delayed Message When URL redirect for Oracle APEX application

Category: APEX,Browser,PL/SQL,URLittichai @ 2:38 pm

I’ve recently moved our internal APEX applications to a new environment. We have new URL for applications. During the transition, even though users are informed with new URL and asked to switch to it, we still want the old URL to redirect to new one for a period of time to ensure the smooth transition.

Oracle APEX provides the redirect capability by making the application Unavailable then perform Redirect to URL. This feature can be found under the Availability section from Shared Components > Definition.

The Unavailable (Redirect to URL) works well if we would maintain the old URL. When user enters the old URL, they will be automatically redirected to new one. The redirect happens very quickly.

In our case, since the old URL will be retired, we’d would like users to be aware of the change. Before redirecting to new URL, we’d like to display a message informing about the move and asking them to take an appropriate action.

To do this, instead of using Unavailable (Redirect to URL), I will use Unavailable (Status Shown with PL/SQL) instead.

The PL/SQL block just simply writes a Javascript to perform redirect. We will give a 3-second delay for users to read the message before the redirect takes place.

BEGIN
  htp.p ('<html>');
  htp.p ('<head>');
  htp.p ('<script type="text/javascript">');
  htp.p ('function delayed_redirect() {');
  htp.p ('  window.location = "http://newURL.company.com"');
  htp.p ('}');
  htp.p ('</script>');
  htp.p ('</head>');
  htp.p ('<body onLoad="setTimeout(''delayed_redirect()'', 3000)">');
  htp.p ('<h1>The application has moved.</h1>');
  htp.p ('<h2>The redirect will NOT work after 3/1/2011. Please bookmark the new URL.</h2>');
  htp.p ('</body>');
  htp.p ('</html>');
END;

Here is what will be displayed for about 3 seconds before going to the new site.

Tags:


Aug 18 2010

Metalink Document for Troubleshooting Materialized View (MView) Create or Refresh

Category: Database,Materialized Views,URLittichai @ 12:45 pm

This is a good Metalink document for troubleshooting issues with creation or refresh or maintenance of materialized views.

MVIEW ‘ORA-’ error diagnosis. For Materialized View CREATE or REFRESH (Doc ID 1087507.1)

The diagnostic is listed by the MView’s ORA errors.

Tags: , , , , , , ,


Oct 27 2007

Read XML data from URL and insert into Oracle

Category: URL,XMLittichai @ 8:26 pm

There are lot of articles (example) talking about how to read a physical XML file and insert into Oracle database. Here is a little bit different. This shows you how to read XML directly from web’s URL then insert into a database table without involving a physical XML file.

To manage the list of URLs, I create a table containing list of URLs. There will be only one URL in this example. But you can use this table to manage multiple URLs if needed.

CREATE TABLE url_tab
(
  URL_NAME VARCHAR2(100),
  URL      SYS.URIType
);

Insert the URL into this table. Note that URL will go to where column type is SYS.URIType.

SQL> INSERT INTO url_tab VALUES
('This is a test URL',
sys.UriFactory.getUri('http://www.domain.com/test.xml')
);

SQL> commit;

This is the sample of the test.xml file.

The XML_DATA_TAB is a target table containing a XMLTYPE column where data will be loaded into.

SQL> CREATE TABLE xml_data_tab ( xml_data xmltype );

Table created.

If there are multiple URLs, obviously you have to loop through all in the list to load data one URL at the time. But in this case, there is only one URL, so here is how to read XML data from an URL and then convert into XMLType data.

insert into xml_data_tab
select sys.xmltype.createXML(u.url.getClob()) from url_tab u;

* Note that if you’re running on the 11g database, you might run into an error on ACL. Please consult Metalink note 453786.1. Watch out for “&nbs” keyword in step #5 box #2. Remove this typo before execution.

SQL> insert into xml_data_tabselect sys.xmltype.createXML(u.url.getClob()) from url_tab u;

select sys.xmltype.createXML(u.url.getClob()) from url_tab u
             *
ERROR at line 2:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1674
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.HTTPURITYPE", line 34

After the fix -

SQL>  insert into xml_data_tabselect sys.xmltype.createXML(u.url.getClob()) from url_tab u;
1 row created.

SQL> commit;
Commit complete.

Note that there is no mechanism for any error checking. You can add yourself if needed. So it is assumed that XML is well-formed.

These are sample queries to extract data from xml_data column.

Retrieve value of attribute -

SQL> selectextractvalue(xml_data, '/crm_data/@product') product_namefrom xml_data_tab;

PRODUCT_NAME
-----------------------------------
electronics

Retrieve value of element -

SQL> select
extractvalue(xml_data, '/crm_data/customer/first_name') first_name,
extractvalue(xml_data, '/crm_data/customer/last_name') last_name,
extractvalue(xml_data, '/crm_data/customer/address') address
from xml_data_tab;

FIRST_NAME           LAST_NAME            ADDRESS
-------------------- -------------------- --------------------
John                 Doe                  12345 Lala lane

Tags: , ,