Infrastructure at your Service

Alain Lacour

APEX Connect 2017 – Day 3

For the last conference day, after the Keynote about “JavaScript: The next Language YOU should learn” by Dan McGhan , I decided to attend presentations on following topics:
– Upgrade your APEX app with zero downtime by using EBR
– Understand and make use of CSS(3)
– Best Practices for APEX Administrators
– APEX Version Control and Team Working
– Database Cloud Services with APEX
– Date, Time, Calendar and Co with APEX
I also got the chance to have a 1:1 talk with Marc Sewtz to expose some wishes about APEX and talk about some customer issue.

JavaScript programming language
JavaScript allows asynchronous programming: main thread can make calls to asynchronous API which return there result via an event/callback queue.
When the web browser parses the page to be rendered the DOM tree is built. That build process is stopped whenever JavaScript is found, until the JavaScript execution is completed. That means the JavaScript can only address the the element that where already put into the DOM tree, not the full page. That explains why people would want to put the JavaScripts at the bottom of the page definition.
Fortunately, there is the JQuery DOM manipulation library which allows developer to abstract from that constraint.
What you also need to keep about JavaScript is:
– functions are the first class
– functions provide scope and closure
In APEX you can make use of JavaScript for AJAX calls by using apex.server.process.
JavaScript is definitely a language that APEX developer should master beside PL/SQL to embrace customer requirements.

Upgrade your APEX app with zero downtime by using EBR:
EBR (Edition Based Redefinition) is a tool in the Oracle database to support online application upgrades.
You can find details about EBR in following Oracle documentation: Technet Edition Based Redefinition
EBR allows you to have your DB looking like 2 DBs, each identified in the normal way by a service (Just like 2 CDBs in the same CDB).
Hot rollover will be enabled by using a traffic director (load balancer).
This introduces end user session to application version affinity.
In APEX you need to create a copy of your application with the changes for the new version. The application version switch is managed with APEX_UTIL.SET_EDITION setting the value of the current application in the APPLICATION_PREFERENCES table.

Understand and make use of CSS(3):
CSS defines the layout design. The basic structure is: selector { attribute : value }
There are numerous selectors which can be combined. Also pseudo classes and elements can be used as reference.
You need to be careful about the cascading order, some strong rules are set to define them. The “!important” tag which overrules should be used as less as possible.
The definition of objects to be rendered is based on the Box Model (Margin – Border – Padding – Content).
There are 2 levels for the definitions:
– Block
– Inline (mainly for the text)
Positions also have multiple definition references:
– static
– relative
– fixed
– absolute
Media queries will allow the definitions for responsive design.
You can verify if some elements your want to use are supported by your web browser by checking the following web site:
http://www.caniuse.com/
I can also recommend you to visit W3C site: https://www.w3schools.com/css/

Best Practices for APEX Administrators:
Following best practice rules were presented based on presenter’s experience:
– Create a dedicated folder to store the APEX installation package (e.g. under the Oracle “product” folder)
– Create a dedicated tablespace for APEX
– Put every worspace on it’s own schema with dedicated tablespace
– Build your own workspace delivery system
– Restrict access workspace administration
– Use a version dedicated folder instead of /i/
– Rename ords.war based on application using it
– Setup automated export and backup of the workspaces and applications
– When patching also keep a copy of the full install package
– Manage downtimes during update operations (only required while sql is running)
– Set ACLs to give only required acces

APEX Version Control and Team Working:
There are different ways to manage team work and version control for APEX development, but none are identical to what is done for other programming languages due to the way APEX works.
What is common in the exposed ways is that the development cycle is about 3 weeks and there is always a Development, an integration, a test and a production environment. Code related to the database (DML, packages, …) is stored and managed with a version control system like GitHub and APEX application exported and pushed to the version control system on a daily basis.
Some people use CI (Continuous Integration) engine to generate a VM with the full test environment from the committed development work.
To manage the deployment of selective features developed you need to use conditional build.
There are different way to export/import APEX applications:
– ApexExport java class
– “apex export” and “apximp” in SQLcl
– “Application Archive” packaged application
– manual export/import
Oracle provides some white paper describing best practices to manage APEX development process:
http://www.oracle.com/technetwork/developer-tools/apex/learnmore/apex-life-cycle-management-wp-3030229.pdf

Database Cloud Services with APEX:
The requirements were about the setup of a private cloud to host about 200TB of data over 300000 schemas.
In order to be able to properly manage the infrastructure following tolls have been created in APEX:
– DB service portal (request management, password reset, reporting, cost tracking, approvals,…)
– DB metadata manager (reporting, interfacing, measurement of space, cpu, aso)
– DB service automation (order management, log management, messaging, maintenance management)
This allowed to raise customer satisfaction, enhance DBA efficiency and metadata maintenance.

Date, Time, Calendar and Co with APEX:
Dates can be represented in different ways in the Oracle DB:
– DATE
– TIMESTAMP
– TIMESTAMP WITH TIME ZONE
– TIMESTAMP WITH LOCAL TIME ZONE
If you dump those data types you will see the details of there implementation and how the Oracle DB stores them.
If you subtract a number to a DATE it will return a decimal number and if you add a number to a DATE you get a DATE.
There are function to manipulate dates like ADD_MONTHS (for DATE) and INTERVAL (for TIMESTAMP).
The EXTRACT function allows to get specific elements of a timestamp.
APEX items are always of VARCHAR2 type, so any date manipulation with implicitly use TO_CHAR and TO_DATE conversion.
The date format is to be set in the APEX application globalization parameters. Most of those parameters map to the DB NLS values by default.
In APEX 5.1 there were some additions to the Calendar like:
– ability to define Dynamic Actions
– JavaScript initialization on parameters
– …
I would recommend to play with the Calendar Sample application to see all new capabilities.

Enjoy APEX!

Leave a Reply

Alain Lacour
Alain Lacour

Consultant