Friday, March 06, 2015

The Ideal APEX Application (When & Where You Write Code)

The real title of this post should be "What I Really Meant to Say Was....".

Bob Rhubart of the Oracle Technology Network OTNArchBeat fame was kind enough to give me an opportunity to shoot a 2-minute Tech Tip.  I love Bob's goals for a 2-minute Tech Tip - has to be technical, can't be marketing fluff, and you have to deliver it in 120 seconds - no more, no less.  So I took some notes, practiced it out loud a couple times, and then I was ready.  But because I didn't want to sound like I was merely reading my notes, I ad-libbed a little and...crumbled under the clock.  I don't think I could have been more confusing and off the mark.  Oh...did I forget to mention that Bob doesn't like to do more than one take?



So if I could distill what I wished to convey into a few easily consumable points:
  1. Use the declarative features of APEX as much as possible, don't write code.  If you have to choose between writing something in a report region with a new template, or hammer out the same result with a lovingly hand-crafted PL/SQL region, opt for the former.  If you have a choice between a declarative condition (e.g., Item Not Null) or the equivalent PL/SQL expression, choose the declarative condition.  It will be faster at execution time, it will be easier to manage and report upon, it will be easier to maintain, it will be less pressure on your database with less parsing of PL/SQL.
  2. When you need to venture outside the declarative features of APEX and you need to write code in PL/SQL, be smart about it.  Define as much PL/SQL in statically compiled units (procedures, functions, packages) in the database and simply invoke them from your APEX application.  It will be easier to maintain (because it will simply be files that correspond to your PL/SQL procedures/functions/packages), it will be easier to version control, it will be easier to diff and promote, you can choose which PL/SQL optimization level you wish, you can natively compile, and it will be much more efficient on your database.
  3. Avoid huge sections of JavaScript and use Dynamic Actions wherever possible.  If you have the need for a lot of custom JavaScript, put it into a library and into a file, served by your Web Server (or, at a minimum, as a shared static file of your application).
  4. APEX is just a thin veneer over your database - architect your APEX applications as such.  Let the Oracle Database do the heavy lifting.  Your APEX application definition should have very little code. It should be primarily comprised of SQL queries and simple invocations of your underlying PL/SQL programs.

My rule of thumb - when you're editing code in a text area/code editor in the Application Builder of APEX and you see the scroll bar, it's time to consider putting it into a PL/SQL package.  And of course, if you catch yourself writing the same PL/SQL logic a second time, you should also consider putting it into a PL/SQL package.

There's more to come from the Oracle APEX team on @OTNArchBeat.

Tuesday, February 10, 2015

Some changes to be aware of, as Oracle Application Express 5 nears...

As the release of Oracle Application Express 5 gets closer, I thought it's worth pointing out some changes that customers should be aware of, and how an upgrade to Oracle Application Express 5 could impact their existing applications.


  1. As Trent Schafer (@trentschafer) noted in his latest blog post, "Reset an Interactive Report (IR)", there have been numerous customer discussions and blog posts which show how to directly use the gReport JavaScript object to manipulate an Interactive Report.  The problem?  With the massive rewrite to support multiple Interactive Reports in Oracle Application Express 5, gReport no longer exists.  And as Trent astutely points out, gReport isn't documented.  And that's the cautionary tale here - if it's not documented, it's not considered supported or available for use and is subject to change, effectively without notice.  While I appreciate the inventiveness of others to do amazing things in their applications, and share that knowledge with the Oracle APEX community, you must be cautious in what you adopt.
  2. In the rewrite of Interactive Reports, the IR component was completely revamped from top to bottom.  The markup used for IRs in APEX 5 is dramatically improved:  less tables, much smaller and more efficient markup, better accessibility, etc.  However, if you've also followed this blog post from Shakeeb Rahman (@shakeeb) from 2010, and directly overrode the CSS classes used in Interactive Reports, that will no longer work in IRs in APEX 5.  Your custom styling by using these classes will not have any effect.
  3. As the Oracle Application Express 5 Beta documentation enumerates, there is a modest list of deprecated features and a very small list of features which are no longer supported.  "Deprecated" means "will still work in APEX 5, but will go away in a future release of APEX, most likely the next major release of APEX".  In some cases, like the deprecated page attributes for example, if you have existing applications that use these attributes, they will still function as in earlier releases of APEX, but you won't have the ability to set it for new pages.  Personally, I'm most eager to get rid of all uses of APEX_PLSQL_JOB - customers should use SYS.DBMS_SCHEDULER - it's far richer in functionality.
Please understand that we have carefully considered all of these decisions - even labored for days, in some cases.  And while some of these changes could be disruptive for existing customers, especially if you've used something that is internal and not documented, we would rather have the APEX Community be made aware of these changes up front, rather than be silent about it and hope for the best.

Wednesday, December 03, 2014

From Zero to Hero....In About 2 Hours



This is an example of a real-world problem, an opportunistic one, being solved via a mobile application created with Oracle Application Express.

First, a brief bit of background.  Our son is 9 years old and is in the Cub Scouts.  Cub Scouts in the United States is an organization that is associated with Boy Scouts of America.  It's essentially a club that is geared towards younger boys, and teaches them many valuable skills - hiking, camping out, shooting a bow and arrow, tying different knots, nutrition, etc.  This club has a single fundraiser every year, where the boys go door-to-door selling popcorn, and the proceeds of the popcorn sale fund the activities of the Cub Scouts local group for the next year.  There is a leader who organizes the sale of this popcorn for the local Cub Scout group, and this leader gets the unenvious title of "Popcorn Kernel".  For the past 2 years, I've been the "Popcorn Kernel" for our Cub Scout Pack (60 Scouts).

I was recently at the DOAG Konferenz in N├╝rnberg, Germany and it wasn't until my flight home that I began to think about how I was going to distribute the 1,000 items to 60 different Scouts.  My flight home from Germany was on a Sunday and I had pre-scheduled the distribution of all of this popcorn to all 60 families on that next day, Monday afternoon.  Jet lag would not be my friend.

The previous year, I had meticulously laid out 60 different orders across a large meeting room and let the parents and Scouts pick it up.  This year, I actually had 4 volunteer helpers, but I had no time.  All I had in my possession was an Excel spreadsheet which was used to tally the orders across all 60 Cub Scouts.   But I knew I could do better than 60 pieces of paper, which was the "solution" last year.

On my flight home, on my iPad, I sketched out the simple 4-page user interface to locate and manage the orders.  As well, I wrote the DDL on my iPad for a single table.  Normally, I would use SQL Developer Data Modeler as my starting point, but this application and design needed to be quick and simple, so a single denormalized table was more than sufficient.



Bright and early on Monday morning, I logged into an existing workspace on apex.oracle.com.  I created my single table using the Object Browser in SQL Commands, created a trigger on this table, uploaded the spreadsheet data into this table, and then massaged the data using some DML statements in SQL Commands.  Now that my table and data were complete, it was now time for my mobile application!

I created a simple Mobile User Interface application with navigation links on the home page.  There are multiple "dens" that make up each group in a Cub Scout Pack, and these were navigation aids as people would come and pick up their popcorn ("Johnny is in the Wolf Den").  These ultimately went to the same report page but with different filters.



Once a list view report was accessed, I showed the Scout's name, the total item count for them, and then via a click, drill down to the actual number of items to be delivered to the Scout.  Once the items were handed over and verified, the user of this application had to click a button to complete the order.  This was the only DML update operation in the entire application.



I also added a couple charts to the starting page, so we could keep track of how many orders for each den had already been delivered and how many were remaining.



I also added a chart page to show how many of each item was remaining, at least according to our records. This enabled us to do a quick "spot check" at any given point in time, and assess if the current inventory we had remaining was also accurately reflected in our system.  It was invaluable!  And remember - this entire application was all on a single table in the Oracle Database.  At one point in time, 8 people were all actively using this system - 5 to do updates and fulfill orders, and the rest to simply view and monitor the progress from their homes.  Concurrency was never even a consideration.  I didn't have to worry about it.



Now some would say that this application:
  • isn't pixel perfect
  • doesn't have offline storage
  • isn't natively running on the device
  • can't capitalize on the native features of the phone
  • doesn't have a badge icon
  • isn't offered in a store

And they would be correct.  But guess what?  None of it mattered.  The application was used by 5 different people, all using different devices, and I didn't care what type of devices they were using.  They all thought it was rocket science.  It looked and felt close enough to a native application that none of them noticed nor cared.  The navigation and display were consistent with what they were accustomed to.  More importantly, it was a vast improvement over the alternative - consisting of either a piece of paper or, worse yet, 5 guys huddling around a single computer looking at a spreadsheet.  And this was something that I was able to produce, starting from nothing to completed solution, in about two hours.  If I hadn't been jet lagged, I might have been able to do it in an hour.

You might read this blog post and chuckle to yourself.  How possibly could this trivial application for popcorn distribution to Cub Scouts relate to a "real" mobile enterprise application?  Actually, it's enormously relevant.

  • For this application, I didn't have to know CSS, HTML or mobile user interfaces.
  • I only needed to know SQL.  I wrote no PL/SQL.  I only wrote a handful of SQL queries for the list views, charts, and the one DML statement to update the row.
  • It was immediately accessible to anyone with a Web browser and a smart phone (i.e., everyone).
  • Concurrency and scalability were never a concern.  This application easily could have been used by 1,000 people and I still would not have had any concern.  I let the Oracle Database do the heavy lifting and put an elegant mobile interface on it with Oracle Application Express.

This was a simple example of an opportunistic application.  It didn't necessarily have to start from a spreadsheet to be opportunistic.  And every enterprise on the planet (including Oracle) has a slew of application problems just like this, and which today are going unsolved.  I went from zero to hero to rocket scientist in the span of two hours.  And so can you.

A demo version of this application (with fictitious names) is here.  I left the application as is - imperfect on the report page and the form (I should have used a read-only display).  Try it on your own mobile device.

Wednesday, October 08, 2014

Is Oracle Application Express supported?


Time to clear up some confusion.

In the past 60 days, I have encountered the following:
  • Two different customers who said they were told by Oracle Support that "APEX isn't supported."
  • An industry analyst who asked "Is use of Oracle Application Express supported?  There is an argument internally that it cannot be used for production applications."
  • A customer who was told by an external non-Oracle consultant "Oracle Application Express is good for a development environment but we don't see it being used in production."  I'm not even sure what that means.
To address these concerns as a whole, let me offer the following:
  1. Oracle Application Express is considered a feature of the Oracle Database.  It isn't classified as "free", even though there is no separate licensing fee for it.  It is classified as an included feature of the Oracle Database, no differently than XML DB, Oracle Text, Oracle Multimedia, etc.
  2. If you are licensed and supported for your Oracle Database, you are licensed and supported (by Oracle Support) for Oracle Application Express in that database.  Many customers aren't even aware that they are licensed for it.
  3. If you download a later version of Oracle Application Express made available for download from the Oracle Technology Network and install it into your Oracle Database, as long as you are licensed and supported for that Oracle Database, you are licensed and supported (by Oracle Support) for Oracle Application Express in that database.
  4. Oracle Application Express is listed in the Lifetime Support Policy: Oracle Technology Products document.

As far as the customers who believed they were told directly by Oracle Support that Oracle Application Express isn't supported, there was a common misunderstanding.  In their Service Requests to Oracle Support, they were told that Oracle REST Data Services (formerly called Oracle Application Express Listener, the Web front-end to Oracle Application Express) running in stand-alone mode isn't supported.  This is expressed in the Oracle REST Data Services documentation.  However, this does not pertain to the supportability of Oracle Application Express.  Additionally, a customer can run Oracle REST Data Services in a supported fashion in specific versions of Oracle WebLogic Server, Glassfish Server, and Apache Tomcat.  To reiterate - running Oracle REST Data Services in standalone mode is the one method which is not supported in production deployments, as articulated in the documentation - however, you can run it supported in Oracle WebLogic Server, Glassfish Server and Apache Tomcat.

Oracle Application Express has been a supported feature of the Oracle Database since 2004, since it first shipped as Oracle HTML DB 1.5 in Oracle Database 10gR1.  Every subsequent version of Oracle Application Express has been supported by Oracle Support when run in a licensed and supported Oracle Database.  Anyone who says otherwise is...confused.

Wednesday, June 18, 2014

Oracle Application Express 5.0 Early Adopter 2 now available!

Just in time for the ever-awesome ODTUG KScope 14 conference...we are happy to announce the availability of Oracle Application Express 5.0 Early Adopter 2.  The response from Early Adopter 1 was overwhelming (with over 4,000 participants), and we look forward to the same great contributions from the APEX community for Early Adopter 2.  You can access the Early Adopter 2 at https://apexea.oracle.com.

As before, the authentication for Oracle Application Express requires an Oracle account.  This is the same account you would use for many Oracle sites, including the OTN Community discussion forums.  If you don't have an account, then simply follow the instructions on the login page to "Sign up for a free Oracle Web account".  However, ensure that you specify the same email address as your Oracle Web account when requesting a new workspace.

The Known Issues will be populated soon, as well the application to review your submitted feedback.  Our team has made tremendous strides since Early Adopter 1, and we continue to believe that APEX 5.0 will become a watershed release for APEX and the community.

Thank you for all of your support.

Wednesday, June 11, 2014

Oracle Application Express 5.0 Early Adopter 2 is on the Horizon



Oracle Application Express 5.0 Early Adopter 2 is on the horizon.  This also means that the current instance of Oracle Application Express 5.0 Early Adopter 1 (https://apexea.oracle.com) is going away soon.  This involves deleting the current database and creating one anew.  Nothing will be migrated or saved.  To try out Early Adopter 2, you will need to sign up for a new workspace.  So if you have anything in your workspace in Early Adopter 1 that you would like to save, now is the time to copy it or export it.  Also understand that there is a good chance that application export files from Early Adopter 1 may not import or function properly in Early Adopter 2.

The response and feedback we've received from Early Adopter 1 has been extraordinary.  There were 4,164 workspaces and over 5,200 users who tried out Oracle Application Express 5.0 Early Adopter 1.  The suggestions and bug reports and feedback have all been enormously valuable, and for which the entire Oracle Application Express team is grateful.

Wednesday, May 07, 2014

Oracle Application Express. Fast. Like a Veyron Super Sport.



A partner from the United Kingdom recently asked me for some statistics about apex.oracle.com, as I had authored something similar in a blog post back in 2009.  This gentleman was proposing a magazine article and sought some updated statistics.  Since I compiled this information for him, I reasoned it was worthwhile to also share this same information with the APEX community.

In the past 7 days on apex.oracle.com:
Total Page Views:              4,875,173
Distinct Applications Used:        5,842
Distinct Users:                    9,048
Total Number of Workspaces:       20,974
Total Number of Applications:     77,478
New Workspaces Approved:             904

As most people know, apex.oracle.com is the customer evaluation instance, for anyone on the Internet to come and "kick the tires" of Oracle Application Express.

However, what I find even more interesting is the internal instance of Oracle Application Express (apex.oraclecorp.com), hosted inside of Oracle for anyone in the company to come along and build applications, requiring nothing but a browser.  It is run and managed by professionals in Product Development IT.  It's used by virtually every line of business in the company (e.g., HR, Product Development, QA, Sales, Marketing, Real Estate & Facilities, Manufacturing & Distribution, just to name a few).  Instead of merely kicking the tires, these are real applications that the business depends upon, even if some of them are opportunistic applications:

In the past 7 days on apex.oraclecorp.com:
Total Page Views:              2,389,593
Distinct Applications Used:        2,023
Distinct Users:                   18,203
Total Number of Workspaces:        2,759
Total Number of Applications:     14,592

And lastly, we have an internal application which is really nothing more than a sophisticated mini data warehouse serving as an employee directory.  Most Oracle employees know it by the name of Aria People.  Tom and others had written this application in lovingly hand-crafted PL/SQL before I even joined Oracle, and we eventually rewrote it in APEX.  As you can imagine, it's used by virtually every employee in the company.  We average 1.4M - 1.5M page views per day.  In reviewing the last 100 days of activity, there was one day (18-MAR-2014) where this application did 3,132,573 page views from 45,767 distinct IP addresses.  The median page rendering time was 0.03 seconds.  In this same application, again looking back across the last 100 days, the busiest hour we had was on 11-MAR-2014, with 171,156 page views in a single hour, from 6,254 distinct IP addresses.  That averages out to 47.543 page views per second.

Oracle Application Express is as scalable as the Oracle Database.  And with some mad Oracle skills, you can scale to great heights.