Monday, August 31, 2015

Adding a Logo or Image to the Login Page in Apex V5

I find the login page a bit bland, so I wanted to add a logo or image to make it look more professional.

I had done this in V4, but V5 is a bit different.

First, find your image and save it to your PC - it doesn't need to be on the server.

Login to APEX as the developer, and select the Application, then select 'Shared Components':



Select the 'Static Application Files' under the 'Files' section:



Click on 'Upload File' and browse to your image and upload it:







The file will be uploaded - make a note of the reference, because that's how you'll tell your application where to find it:



Navigate to the Application Builder page, and select the 'Login' page (usually 101) to edit it:

Click on the 'Login' under regions to edit the region, and scroll down to the 'Attributes' section:


In the 'Region Image' item, this is where you put the reference that was shown after you uploaded the image : #APP_IMAGES#charts.jpg

Click on 'Apply Changes' to save it.

OK, now we have the image uploaded and referenced in the region, run the page to see it:



Whoa, that's not what I expected - the image was quite large, and it defaults to the original size.

Go back to the "Attributes" section of the region and resize it:


Click on 'Apply Changes' to save it, then run it again:


Much better.

You can fiddle around with the settings to re-position it on the page, for example create a new region above it and put the logo / image there.












Sunday, August 23, 2015

Running 2 versions of APEX in the same ORACLE_HOME

I have just started working on a site which uses APEX, so thought I'd look at creating a dashboard app to see database activity.

Logging into APEX I had a bit of a shock to see that they were still using V3.

Not wanting to upgrade all their applications just for my own benefit, I decided to see if I could run V3 and V5 in the same database.

It was soon apparent that no, that can't be done. Even though the schema and tablespaces would be V5, there are some SYS objects used by APEX that would mean I would break the V3 environment.

My next thought was to see if I could run APEX V5 in a different database but in the same ORACLE_HOME.

I needed to be careful not to impact their stuff.

So, first step, I used dbca to create my own database to hold APEX V5.

I then created a new directory in the ORACLE_HOME for V5 and copied the V5 zip file from the web into it.

oracle@test_host.APEXTST> cd $ORACLE_HOME
[/opt/oracle/product/11.2.0.3/db1]
oracle@test_host.APEXTST> ls | grep apex
apex 
apexv5    

Note that I left the original apex there. Don't want to touch that.

I then copied and extracted the apexv5 zip file under the apexv5 directory. This created a new directory called 'apex'. I thought that this was a bit redundant, so tarred all the files up and moved them to the apexv5 directory (which turned out to be a mistake, see below).

I navigated to the apexv5 directory, connected to my database as sys / sysdba and ran the apexins.sql :

SQL> @apexins.sql sysaux sysaux temp /i/

This ran through OK, so I ran the @apxchpwd.sql script and set the password for the ADMIN user,

I finally ran the apex_epg_config.sql script, and had a problem:

SQL> @apex_epg_config.sql /opt/oracle/product/11.2.0.3/db1/apexv5

. Loading images directory: /opt/oracle/product/11.2.0.3/db1/apexv5/apex/images
declare
*
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "SYS.XMLTYPE", line 296

ORA-06512: at line 16

The 'apex' portion of the path is hard-coded in the config script - but this doesn't exist for my install, the images folder is directly under 'apexv5'.

So I decided to create a new directory under 'apexv5' called 'apex' and move all the files there.

cd /opt/oracle/product/11.2.0.3/db1/apexv5/
mkdir apex
mv * apex
(ignore the warning about moving the directory)

I then re-ran the config script and this time it worked because it could find the 'apex' directory.

SQL> @apex_epg_config.sql /opt/oracle/product/11.2.0.3/db1/apexv5

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

. Loading images directory: /opt/oracle/product/11.2.0.3/db1/apexv5/apex/images

Directory created.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Commit complete.

Directory dropped.

timing for: Load Images
Elapsed: 00:03:01.68

PL/SQL procedure successfully completed.

Commit complete.

Unlocked the anonymous account, ran the acl script (see my earlier post here), and tried connecting to the V5 APEX, which worked.

So, the short answer is that you can't run 2 versions of APEX in the same database, but the next best thing is to create a new database and run the different version in that. However, you must make sure that you don't overwrite the existing $ORACLE_HOME/apex directory when you unzip the file. I always take a backup of the database as well as the apex directory under $ORACLE_HOME when doing any APEX upgrade.