APEX 5 Data Load Wizard ~ Slight Updates Mean Changes to Customized Load Pages

Slight changes in the APEX 5 Data Load Wizard meant our customized Data Load pages needed some attention to work properly in APEX 5.

Ever customize the APEX Data Load Wizard pages?  We did so in APEX 4.2,  to

  • Accomodate data change logging requirements. We needed to log every change made to incoming data.  The APEX Data Load Wizard will make those changes for you, but not log them.
  • Allow users to upload XLSX, XLS or CSV files.

So we customized. And all worked well, until we upgraded to APEX 5.

In APEX 5, all our data uploads all broke, giving an abrupt “no data found” error during the file upload.  Geez, it hadn’t even got to all our custom stuff yet!

Well, a little digging into the APEX 5 Data Load Wizard-generated pages and collections gave me the answer. And we are back in business.

This is good reminder that any time you play outside the APEX sandbox – use anything other than the standard wizards and documented APIs –  you are subject to things breaking upon upgrade. We know this and accept it … and we really should PLAN for it. Even point releases.

So what changed?

The Data Load Wizard uses a series of collections behind the scenes to store the data being uploaded and processed:

  • SPREADSHEET_CONTENT – Uploaded (or copied) data
  • PARSE_COL_HEAD – As-uploaded column headings
  • LOAD_CONTENT – Content to be loaded, plus Error and Action information in c047, c048 and c049.
  • NOT_LOAD_CONTENT – Content to NOT load, including the same Error and Action information in c047, c048 and c049.
  • LOAD_COL_HEAD – Mapped column headings; the columns to be loaded.

The collection names pretty much tell you what each collection does.

The APEX 5 DLW now also creates a new collection:

  • SPREADSHEET_SMTP – One member, the uploaded spreadsheet sheet name.  (Not sure what happens if there are multiple sheets … task for another day.)

Was this the problem?  No.  This new collection was getting created in APEX 5 – clearly not the problem.

What was? Behind the scenes, the APEX 5 DLW added a new element as  the last element in the PARSE_COL_HEAD collection, USE_APPLICATION_DATE_FORMAT.  As soon as I added this element to my collections, all worked happy again.

How did I find it?  Plain old triage. I knew from experience that upon upload the SPREADSHEET_CONTENT and PARSE_COL_HEAD columns got populated. Since we did not get beyond the upload- clearly something was happening  – missing – there.  I created some APEX 5 data load wizard pages based on the same table, and step by step examined what was there or not in session state.  Our customization populated PARSE_COL_HEAD (for a variety of reasons re saving the uploaded file, off point for this post).  But it was not adding the USE_APPLICATION_DATE_FORMAT element.  A simple PL/SQL change corrected that, and the no-data-found went away.

Note that this solved our APEX 5 data load issue.  I have seen other cases of the same no-data-found message on other posts in the APEX Community and stackoverflow.com – these may or may not be the same issue I describe here, and the pre-APEX 5 posts are definitely not. Suffice it to say if one customizes any part of the APEX Data Load Wizard, one adopts  the responsibility of keeping up with all of the nuances of the Data Load Wizard for the life of that application.

Is there something else different behind the scenes?  Yes, a few things off topic for this post.  Is there more? Could be, but it is not effecting my customized data load  pages right now.  Will it break on the next upgrade?  Maybe, and we will of course be watching, testing and prepared to adjust as needed.

Lessons reinforced:  Customize only when necessary.  Plan for, allocate time for, test, and adjust as necessary before every upgrade. Common sense stuff that sometimes gets back-seated in the haste to upgrade.

Migrate BI to APEX 5?

Just back from presenting Migrating BI to APEX 5 at RMOUG Training Days 2016.  Great conference!  Great experts on all Oracle technology. If you have to pick one short sweet conference a year, this is it.

Ever thought of replacing your under-utilized, expensive or outdated BI tool with a suite of APEX Interactive Reports?  In *SOME* cases this makes sense:

  • Your Data Display requirements are reasonable – i.e. users are happy with seeing and working with a few thousand rows or less at a time.
  • Your BI feature requirements include APEX IR Actions (select, sort, filter, chart, pivot, group by aggregate, save, download), and
  • Your BI feature requirements do NOT include BI analysis, unlimited drill-downs, automatic or integrated analysis (such as percents, rank, etc), drag and drop report creation/analysis, and/or MS-Excel-like features. IF you want these, you have to build them.
  • You have APEX resources to plan, design, build and maintain the APEX app
  • You have Database Architects/Developers to plan, design, build and manage the data structures in the database required to consolidate and serve your data ( materialized views, indexes, or other rollups as needed as licensed for).
  • You are prepared to design, build and tune all for performance (as you always should anyways!)
  • You do NOT require out-of-the-box PDF Printing for the as-displayed data set.  Those who own and extensively use BI Publisher may not want to give up this printing luxury IF moving to APEX means doing so. There are many many printing uses cases for which there are many solutions – ensure you have a solution that fits (and is reasonable to implement) before you jump.

Given all this, it just might work for you  It has for many customers, successfully.  The caveats are:

  • If you need a feature that APEX does not natively supply, you must build it.
  • Dynamic Actions are great -but need to be implemented wisely. They may not always perform well with volumes of data.
    • ex: Dynamic parameter selection => Good.
    • Dynamic parameter selection AND dynamic refresh of the IR with the new parameters (a new query against the source data structure) may/will not perform so nicely, depending on the volume of data.
  • Some features are just not reasonable to build in APEX:
    • ex: True Excel-Like behavior
    •        Dynamic Aggregate adjustments

So – want to replace that aging Discoverer installation?  Consider APEX 5.

In planning pages, menus and features, consider these tips:

  • Plan and meticulously tune all structures – materialized views, CUBEs or ROLLUPS, or whatever works for your data. Anything slow here is magnified slow in APEX.
  • Give users mandatory parameters.  This forces up-front filtering, to reduce the result set to a reasonable size AND gives you a ready-made drill path.  We want reasonable size for reasonable performance of all interactive features.
  • Try 3 to 5 Parameters – More gets tedious for end users if they have to select every time.
    • A Temporal (Year. Quarter, Month), and Spatial ( Country, State, City ) and one or few others specific to your data.
    • Consider using Page Zero or building  a Plugin for displaying the same parameter set on all or several pages. (Yes, Plug-Ins can be used locally!)
  • Use a flag to control when data displays. This allows users to filter (using your parmeters Plugin) first, then wait for data to display.  Plan so users do not incur a big wait right up front.
  • Consider multiple IRs on one page, each containing different aggregates of you data depending on the parameters.  The parameters chosen control which ONE of thes IRs displays at any given time.
  • Consider multiple IRs on one page, each containing different Action Item features.  Authorizations for authenticated users control which ONE of thes IRs displays at any given time.
  • Plan and build drill paths wisely.  Intelligently build useful drill paths.  A drill on every column is not necessary. Drills on key columns are nice to have.

Know Your Users, and know what they really do with the data.  That helps you to design and build truly useful data sets and features.

Still not convinced? On the Fence ?

Consider waiting for APEX 5.1 Interactive Grid.  Previews of this new region type show some promising features that BI folks may find interesting:

  • Drag and drop headings
  • Lazy loading – an option to display the frame then the rest of the data
  • Loading data in pages, as opposed to one big result set.

Doesn’t seem like much, but these are big useability improvements , especially when we are considering paging through volumes of data.  Were I to be starting a BI migration project now,  I would investigate the APEX 5.1 Interactive Grid previews and plan my project accordingly.

In the meantime, see my Migrating tBI to APEX 5 slides here, and  if you have specific questions, reach out:

ODTUG Board of Directors Election ~ Vote!

Vote for the ODTUG Board

The ODTUG Board of Directors election is underway now.  ODTUG memebers, this is your chance to choose 5 new board members for the 2016-2017 term.

Again this year there is a stellar selection of candidates.

Why do I run?  I have served ODTUG in many capacities behinds the scenes and as Editor of the Technical Journal, and want to :

  • Bring more quality learning material in all formats, online and offlne, to all Oracle developers:
    • more online material in more formats, and
    • more meetups to bring the message local.
  • Encourage women in technical fields:
    • to strive for higher positions in those careers, and
    • to have greater confidence in what they bring to the table technically and personally.
  • Strengthen the ODTUG Communities so that material and answers from ODTUG experts shows up in every search. We cannot keep our knowledge behind (fire)walls!

ODTUG should be the Oracle Developer go-to resource for learning, online and locally.  As a board member I will work to increase ODTUG’s online presence and increase ODTUG’s regional and local presence via co-hosted meetups.

There are many qualified candidates – regardless of who you vote for, VOTE!

Read all the campaign statements and biographies of the candidates.

ODTUG is the best source of learning for all Oracle development tools ~ your vote ensures we not only stay that way but grow as fast or faster as the tools we use.

To vote, please visit https://www.associationvoting.com/odtug and enter your email and Voter ID exactly as shown in the email you received from ODTUG (actually from announcement@associationvotiing.com) on or about 10/06/2015.

Not a member? Join!  You are missing out on the best Oracle training in the world, at minimal investment of a year’s membership fee. Betteryet, VOLUNTEER and quadruple the learning advantage.

As always, Happy Coding!

BTW ~ Accepting Viedos, Blog Posts, papers, podcasts – send us your excellence for publication in the ODTUG Technical Journal.

Karen

ODTUG Technical Journal Corner

ODTUG Technical Journal – submit papers now!

APEX 5 Interactive Reports, Part II

All APEX developers should be aware of the APEX 5 new features in order to pass these features on to their users and to leverage new development efficiencies. All developers who have customized interactive report appearance, altered Actions, written IR dynamic actions or otherwise enhanced an IR in any earlier APEX version (most of us?) need to know the behind-the-scenes details of APEX 5.0 IRs. The changes are significant, and unless the APEX standard APIs have been used the customization may not upgrade smoothly.

As usual for a new APEX release, APEX 5 introduces new IR features: new and enhanced Acton Menu features, some cosmetic uplifts and some report management improvements. All of these are covered in Part 1 of this series. With APEX 5, the major IR changes are behind the scenes – APEX IRs have been rebuilt from the inside out.  Both the “inside” changes – the JavaScript engine – and the “outside” changes- CSS classes and Ids – are significant.  The important note for developers is that because of this re-architecting, even when developers used the APEX-standard dynamic action or plugin frameworks, if the customization code references the pre-APEX id’s and class elements, the customization code will need to be refactored to upgrade.

Why so many changes, and why such a drastic change? Several reasons. The revised IR code allows for:

  • Multiple IRs on one page (perhaps the biggest new feature, to be described in detail in later sections of this paper)
  • Modal dialogs
  • The Universal Theme and Theme Roller customizations
  • APEX overall usability and accessibility

These features, particularly multiple IRs on a single page, were just not possible with the pre-APEX IR architecture. The new code makes sense, when one considers that multiple IRs on a single page was not possible with the legacy IR structure – something had to change. With all of the other IDE and end-user interface changes in APEX 5, the IR changes make sense.

The downside is, developers who have tooled outside of the APEX sandbox must now invest some time in upgrading to the new IR structure and JavaScript. All IR customizations made outside of the standard APIs may not work in APEX 5. Developers who have made such changes will need to refactor their customizations.

The following sections discuss the APEX 5 IR structural changes in detail. The Know Your Users section applies to all developers, and is repeated here as a reminder that all configuration and customization should have one goal, to serve user requirements. The Changes section addresses the CSS and JavaScript changes such developers need to know to plan their upgrade to APEX 5.

Know Your Users

IRs are very powerful in that they deliver a lot of end user functionality with minimal developer effort. However, it is the developer’s responsibility to maximize IR effectiveness by using the declarative settings to tailor the IR to end user needs.  This means the developer needs to be aware of such things as overall security needs, how user use the data set, which Action Menu features should be prohibited or restricted, how much training end users will require, which download options are required, and how users are likely to use Saved reports. It is the developer’s job to prepare and deliver the appropriate IR query and action set to support them. If customizations beyond standard IR features are required, they should first be implemented using standard APEX Pis, and only as a last resort achieved through custom coding.

In short, Know Your Users. Watch what they do, because what they really do is not necessarily what they say the do or need. Deliver the functionality they need, restrict the features they should not have, and ensure the data set they receive is useful to them.

Changes

Turn and face the strange ch ch ch changes …

D. Bowie

APEX IRs have been reengineered to accommodate multiple interactive reports on one page, and in keeping with the APEX5 overall style, usability and accessibility improvements. The underlying architecture is quite different than previous versions.  It is important the developers understand these changes, particularly when adding dynamic actions, plugins or any other customizations.

CSS Changes

The main CSS changes are in a different pattern of class and id nomenclature.  The old apexir_<element> id constructs are gone, replaced by a series of a-IRR-<element> classes and revised id names. Figure 1 shows the pre-APEX 5 IR HTML and CSS structure. Note the apexir_<element>  id and class names.  Figure 2 shows the APEX IR structure.  Note the new [STATIC_ID]_<element> id name, and the a-irr-<element> class names.

Fig1_Pre5_apexirdIds

Figure 1 – Pre-APEX 5 apexir_ Ids

Fig2_Axp5IrIds

Figure 2 – APEX 5 STATIC_ID_ Ids and a-IRR- Classes

The APEX 5 pattern is readily visible:  apexir_<element> ids are now renamed to STATIC_ID_ <element>, where STATIC_ID is the static id of the IR region, whether it was declared by the developer or assigned by APEX, in which case it has the format R123456789012345.  It is much easier to understand the underlying ID structure, especially when there are multiple IRs on the page, when declared static ids that make sense are used. There is a Static Id attribute on every IR – in earlier versions it was most often left blank. With APEX 5, the Static Id is important in passing filters to specific IRs, and in the structure of the IR itself.

JavaScript Changes

Pre-APEX 5, the APEX IR JavaScript is contained in the file widget.interactiveReport.js. Post APEX-5, the APEX IR JavaScript is contained in the file widget.interactiveReport.js.  The similarity ends there…. well, almost.  Reviewing the two files, one recognizes the same functions – actually widget methods – that correspond to the action menu actions, but the construction of the functions – the definition of the widget methods – is different, as is their implementation.

The Supported Way

The SUPPORTED way to influence APEX IRs is to “use the standard APIs”.  That includes apexrefresh, and the APEX_IR API. Let’s see what we can do with these.

apexrefresh is the documented, supported way to refresh APEX components from JavaScript. That includes refreshing APEX IRs. The syntax is simple:

apex.event.trigger(‘#myIRRegionStaticID”, “apexrefresh”);

For more specific IR settings, use the supported, documented APEX_IR API (https://docs.oracle.com/database/121/AEAPI/apex_ir.htm for APEX 5). To user most calls of APEX_IR, one needs to get the region id of your interactive report.   As simple example, the code sequence to programmatically reset an IR to its default configuration uses the APEX_IR.RESET_REPORT procedure: is:

DECLARE
  v_region_id APEX_APPLICATION_PAGE_REGIONS.REGION_ID%TYPE;
BEGIN
  SELECT region_d INTO v_region_id
    FROM APEX_APPLICATION_PAGE_REGIONS
   WHERE application_id = :APP_ID
    AND page_id = :APP_PAGE_I
    AND static_ic = ‘MY_IR_STATIC_ID’;

  APEX_IR.RESET_REPORT(
   P_page_id => :APP_PAGE_ID,
   P_region_id => v_region_id,
   P_report_id => NULL);
END;

Of course such code would be improved before production use by wrapping in a procedure, adding error catching and validations as needed for your situation.

In addition to the APEX_IR possibilities, there always the declarative RIR and CIR settings, discussed in Part I of this series in the Summer 2015 RMOUG  SQL> UPDATE.

So we can do all the basics using supported, documented means. But what about our more complex situations, where we have already strayed into unsupported territory with IR enhancements in earlier APEX versions?

The UNSupported Way

In APEX 4.2 and earlier, when there is always only one IR on a page, the widget is attached to the gReport element – the IR – and there is always only one gReport element on the page. One can inspect the JavaScript on the page and readily see calls to widget functions.

For example, inspection of the Search Column icon, shown in Figure 21, clearly shows the onclick action is a call to gReport.dialog2(“SEARCH_COLUMN”).

Fig3_apx42gReprt

Figure 3 – APEX 4.2 gReport.dialog2 Call on Search Column Icon

Further inspection of the IR JavaScript and HTML reveals that gReport.dialog2(‘parameter’) is the widget method for opening the ‘parameter’ dialog window, where ‘parameter’ values correspond to the Action Menu options.

Inspection of the APEX 4.2 Go button on the toolbar shows us the gReport.search call, shown in Figure 4.

Fig4_Apx42Go

Figure 4 – APEX 4.2 IR Toolbar Go Button gReport.search Call

With APEX 4.2, because we can clearly see how these two widget methods, gReport.dialog2 and gReport.search are used, we are actually quite confident in using them in our customizations, even when we know their direct use is unsupported. This is jQuery in APEX – we trust that this stuff is solid. 🙂

Well, in APEX 5, the familiar gReport.dialog2(…) and gReport.search(…) functions calls are not there.  In fact, the familiar gReport element is not there at all.  Figure 5 shows the IR Toolbar Go button HTML in APEX 5. No gReport in site – no jQuery is visible here.

Fig5

Figure 5 – APEX 5 IR Toolbar Go Button – No gReport.search!

Note again that all out-of-the-box APEX IRs will automatically use the new jQuery widgets, seamlessly.  The problem is, in APEX 5, all calls to the undocumented gReport stuff do not work. Any customization that makes gReport method calls, or extends the interactive report widget will need to be refactored.

So how do things match up? What replaces gReport? Let’s go back to some jQuery UI widget basics. The APEX team has used the jQuery widget factory to build (rebuild) the interactive report and action menu widgets (and many others within APEX 5).

The best reference I have found on jQuery UI widgets is on jQuery UI, How to Use the Widget Factory, at https://learn.jquery.com/jquery-ui/widget-factory/how-to-use-the-widget-factory/  If you are not familiar with jQuery widgets and the jQuery widget factory, this how-to article will help understand jQuery widgets in general, which will help you understand how the APEX interactive report and action menu widgets work.

Note: If you are not familiar with jQuery and  jQuery UI widgets, then seriously consider NOT making any unsupported customizations to the APEX IR widgets, at least until you learn more and become entirely confident in your ability to support yourself and your code.  This post does not contain sufficient information to make your first customization attempt.

The best reference for explaining how the APEX 5 IR widget works is by John Snyder, at http://hardlikesoftware.com/weblog/2015/05/12/apex-5-0-interactive-report-customization/.

Armed with the information in these two articles, we can figure out our APEX 5 IR widget code.

Widgets are attached to DOM elements.  Widget methods are the functions that define what the widget does – the actions. Methods prefixed with _ are private methods. Every widget has an options method that lists the options (attributes).  To view all options, use the option keyword:

$(selector).widgetName("option");

To view a specific option, simply state the option:

$(selector).widgetName(“option”, "optionname");

Adding a second parameter sets the value of the option:

 $(selector).widgetName(“option”, "optionname",100);

The basic call to a widget method takes the format

$(selector).widgetName("method");

If the widget method has parameters, add the parameters after the method name:

$(selector).widgetName("method", “param_1”, “param_2”);

Now let’s apply that context to our APEX IR.

The key information John gives us is that in APEX 5, the IR widget appends “_ir” to the static id of the IR, and “_actions_menu” to the actions menu widget .  So if my IR has a static id of DEMO_IR, we know the ids for the IR widget and for the IR actions menu.  To view all the options for these widgets, in the Console window use these commands:

$(“#DEMO_IR_ir”).interactiveReport(“option”);

to show all the IR widget options, and

$(“#DEMO_IR_actions_menu”).menu(“option”);

to show all the action menu options.

There are quite a few options for both – to learn more about the IR and action menu widgets, definitely run these jQuery commands in your browser Developer Tools Console window.  View the options, then experiment with calling some of the options. The IR widget options correspond to the IR attributes.  The menu widget options correspond to the IR action menu options, and the iems correspond to the menu actions. These will be familiar to developers who are familiar with IR settings.

The IR widget options include: actionsMenu, afterRefresh, aggregate, chart,columnSearch, compute, controlBreak, fixedHeader, flashback, groupBy, help, highlight, and more. Those familiar with IR action menu settings will recognize these as IR attributes, including action menu settings.

The action menu options include 15 items, with id’s,  like irSaveReport, irSaveDefault, irReset, irDownload and irNotify. (There are more – inspect for yourself!)

Following John’s blog, and experimenting with various options in the Console, I was able to find these interesting things:

$("#DEMO_IR_ir").interactiveReport("option","currentRowsPerPage");

returns the current rows per page setting.

 $("#DEMO_IR_ir").interactiveReport("refresh");

refreshes the IR.

$("#DEMO_IR_actions_menu").menu("find","irDownload");

returns the irDownload object.

[$("#DEMO_IR_actions_menu").menu("find","irDownload").action();

invokes the action method of the irDownload object – it opens the IR Download dialog. Translated, it finds the irDownload object of the DEMO_IR interactive report actions menu and calls its action method.

I leave the rest to your own experimentation. Clearly we are not totally in the dark here, once we know how the widgets work.

Note: The IR static id is optionally declared by the developer. If a static id is not declared, APEX assigns a long ugly one – therefore, it is best to assign a static id when one plans on using referencing it in JavaScript.

It is unclear at this point whether and when a JavaScript API will be provided to standardize and facilitate calls to the IR functions – particularly those for Reset, pagination, and Search options. Talks at KScope15 suggested a future release of an IR API is likely, but no hint of what or when. Until then, remember that customizations that do not use standard APEX APIs are not supported.

As in earlier APEX versions, developers who customize the APEX IR JavaScript widget are in unsupported territory. &amp;nbsp;Which does not mean altering the IR widget or using its calls directly cannot be done, it means that doing so is not supported, and will likely not upgrade smoothly or at all to future versions. (Sound familiar?)

Note: In earlier APEX versions, there was less declarative JavaScript capability and therefore more developer customizations. As APEX advances and incorporates more declarative JavaScript, it is &amp;nbsp;more important to stay within the standard APIs when making customizations, to avoid difficulties when upgrading.

A few code comparisons will illustrate further emphasize the differences between the APEX 4.2 widget and the APEX 5 widgets.

The pre-APEX 5 RESET function is:

/**
* Reset current&amp;nbsp; worksheet report to initial state
* @function
* */
this.reset = function() {
that.action('RESET', false, false, false);
};

The APEX 5 RESET function is a private method:

/**
* Reset current worksheet report to initial state
* @function
* */
_reset: function() {
this._action( "RESET" );
},

Not exactly the same, but close, and note the APEX 5 private method.

The pre-APEX 5 Search function is:

/**
* Runs the basic search functionality of the worksheet.
* @param {String} [pThis] if set to SEARCH check
* @param {Number} [pRows]
*
* */
this.search = function(pThis, pRows) {
var lSearch = that.item.search();
var lSearch_Col = that.item.search_column();
var lReport = $v('apexir_REPORT_ID');
var lTemp;
if (pThis='SEARCH') {
if (pRows) {
that.get.addParam('p_widget_num_return', pRows);
} else {
if ($x('apexir_NUM_ROWS')) {
that.get.addParam('p_widget_num_return', $v('apexir_NUM_ROWS'));
}
}
}
if ( apex.item( lSearch ).isEmpty() ) {
that.get.AddArrayItems2($x_FormItems('apexir_TOOLBAR'),1);
that.pull(lReport);
} else {
if (pThis='SEARCH') {
//lTemp = [$v('apexir_CURRENT_SEARCH_COLUMN'),'contains',$v(lSearch),$v('apexir_NUM_ROWS')];
that.get.AddArrayItems2($x_FormItems('apexir_TOOLBAR'), 1);
pThis = 'QUICK_FILTER';
} else {
lTemp = [this.current_col_id, '=', $v(lSearch)];
pThis = 'FILTER';
that.get.AddArray(lTemp,1);
}
that.action(pThis, 'ADD');
}
$s(lSearch, '');
};

The APEX 5 SEARCH function is a private method:

/**
* Runs the basic search functionality of the worksheet.
* @param {String} [pThis] if set to SEARCH check
* @param {Number} [pRows] Optionally set to control the number of rows displayed, needs to
* be done with the searc because the user could enter a new search, then select the rows
* which would issue the search
*
**/
_search: function( pThis, pRows ) {
   var lData, lFArrays,
   o = this.options,
   lSearch = this._getElement( "search_field" ).val();
   // If pRows passed, this has been changed and the new value used, but only allow if 
   // either actions menu
   // row select, or search bar row select is enabled
   if ( pRows && ( o.rowsPerPage || o.rowsPerPageSelect ) ) {
       o.currentRowsPerPage = pRows * 1;
   }
   lFArrays = this._utilGetFormElAttributes( this._getId( "toolbar_controls" ) );
   lData = {
     f01:    lFArrays.ids,
     f02:    lFArrays.values
   };
   if ( lSearch === "" ) {
     this._pull( null, this.reportId, lData );
   } else {
     this._action( "QUICK_FILTER", lData );
   }
  },

The APEX IR interactiveReport widget _get  function controls all the functions of the interactive report. The complete widget.interactiveReport.js.5.0.0.00.NN can be inspected from its location:

[code]&amp;lt;host server and port&amp;gt;/i/libraries/apex/widget.interactiveReport.js?v=5.0.0.00.NN [/code]

Where the <host server and port> are the http/https and host server name and port of your APEX installation, and NN is the exact version number in your APEX 5 installation’s widget.interactiveReport.js library.

The above code excerpts are not meant to be any sort of how-to – their purpose is only to illustrate that there are differences and any developer who has pre-APEX 5 customizations that rely on the pre-APEX 5 form of widgetinteractiveReport.js will need to review their code carefully and refactor when upgrading to APEX 5.

gReport to Widget Method?

So, what to do with all those unsupported gReport calls?  Refactor to use the APEX 5 widget calls and remain unsupported? I cannot tell you.  Perhaps more will be revealed in APEX 5.1 ?

To Risk to Not to Risk?

A comparison of the main functions of the pre-APEX 5 and APEX 5 interactive report JavaScript is presented in Table 2 of the APEX 5 Upgrade Cheat Sheet, in the Appendix. This comparison alone is not very helpful – it simply illustrates that a similar, but not exact function/widget method exists for each of the APEX IR actions. Developers that have customizations that rely on the old IR JavaScript must review each  function carefully and update their code accordingly.

Again, it is not expected that customized use of the IR JavaScript functions will be supported. Developer beware …

The recommendation is to use dynamic actions that call the APEX_IR API functions and procedures to achieve the desired results.  This method mmay mean more coding, but this approach, using the APEX dynamic actions and the published APIs – will be supported going forward.  Direct use of the IR and action menu widget methods is not supported.  IF you go this way, be prepared to refactor (again) going forward.

Upgrade (refactor) Example

The following simple example demonstrates the changes needed in an existing dynamic action to work successfully in APEX 5.

This simple Execute JavaScript dynamic action changes the background color of a row based on a certain value in the FLAGS column. Yes, this simple highlight could have been done with a pre-set IR Highlight action, however, to not clutter the control panel, to prevent users from editing this affect and for other business reasons this appearance change was done via JavaScript. (This dynamic action was one of several on the IR, each of sufficient complexity that it was not practical to implement all of them as IR actions).

var rows = $('table.<strong>apexir_WORKSHEET_DATA</strong> tbody tr:gt(0)');
rows.each(function(idx)  {
var Flags = $(this).children("td[headers=<strong>'FLAGS</strong>']").text();
if( Flags == 'Outlier')
{
$(this).children("td").css("background-color","#FCF067");
}
});

Simple enough, but this does not upgrade to APEX 5 because the apexir_WORKSHEET_DATA id no longer exists, so the table.apexir_WORKSHEET_DATA  search returns nothing. In fact, in APEX 5, this dynamic action does nothing at all.

The changes needed to make this dynamic action work in APEX 5 are:

  1. Replace the apexir_ component with its corresponding APEX 5 irr- component
  2. Ensure the column name/alias is in fact the APEX 5 column id.

To find the APEX 5 column id, use browser developer tools to inspect the column in question. The column id will be in the format C999999999999 by default, and will be the column alias when there is a clear column name..

The updated code looks like this:

var rows = $('table.<strong>a-IRR-table</strong> tbody tr:gt(0)');
rows.each(function(idx)  {
var Flags = $(this).children("td[headers='<strong>FLAGS</strong>']").text();
if( Flags == 'Outlier')
{
$(this).children("td").css("background-color","#FCF067");
}
});

And in fact the updated code highlights outlier rows, as desired, as shown in Figure 6 (below)..

Fig6_ColorCodedIR

Figure 24 – APEX 5 IR Dynamic Action Updated

The above highlight-row dynamic action upgrade is a very simple example. Your examples may be as simple, or very much more complex. The time to refactor will of course depend on the amount and complexity of the customizations to be upgraded. In this author’s case, the upgrade was straightforward – accomplished in less than two hours including testing, for the series of 6 moderately complex dynamic actions on the page. Your mileage may vary.

APEX 5 IR Upgrade Cheat Sheet

As promised, this post includes a “cheat sheet” for mapping pre-APEX 5 CSS and Ids to their APEX 5 equivalents. The cheat sheet is included in the appendix. Note that a cheat sheet is just a guide – it does not replace doing your homework and learning your subject matter. If you have read the above sections, you have all the information you need to map out your refactoring – you won’t need a cheat sheet.

Every developer should inspect their code and their particular interactive report in APEX 5 and validate their own mappings. The reason is, each interactive report may be configured differently. Different configurations will incur different combinations of IR class and id settings.  This author’s recommendation is to use the enclosed cheat sheet as a guideline in beginning your upgrade work, but always always inspect and double-check the mappings in your specific IR and in your specific APEX 5 environment.

Summary

APEX 5 IRs contain some noteworthy new features for end users and developers. For end users, the most significant of those are the improved look-and-feel, modal dialogs, the enhanced GROUP BY action, the new PIVOT action, and the option for multiple IRs on a single page. Part 1 of this series covered the APEX 5 new and enhanced features for end users.  For developers, the APEX 5 IR construction changes are more significant as the underlying architecture has completely changed. Developers who have done customizations on IRs in previous APEX version may need to refactor their  code to follow the new APEX 5 IR structure and widget methods. With APEX 5, the overall power of APEX IRs has increased, but when it comes to customizations, some upgrade work may be necessary.

References

Manually Refreshing APEX Components
http://docs.oracle.com/cd/E59726_01/doc.50/e39147/extend_app002.htm#HTMDB30267

APEX 5.0 Interactive Report Customization, John Snyders
http://hardlikesoftware.com/weblog/2015/05/12/apex-5-0-interactive-report-customization/

jQuery UI: How to Use the Widget Factory
https://learn.jquery.com/jquery-ui/widget-factory/how-to-use-the-widget-factory/

The APEX 5 APEX_IR API Documentation

https://docs.oracle.com/database/121/AEAPI/apex_ir.htm

Appendix

The APEX 5 IR Upgrade Cheat Sheet

As I mention above (or was that in Part I?), one really does not need a cheat sheet for this upgrade – the more important thing is to note the pattern of class names and CSS element names in the new APEX IR structure:

apexir_<element> ids are now renamed to STATIC_ID_ <element> ids

But for those who want one, the Cheat Sheet I put together over a year ago now is at then end of the complete document, in the link below. No doubt I missed some details – but go for the pattern, THINK and figure things out. You’ll do fine.  If you get stuck, contact me 🙂

Complete APEX IR Part II, w Appendix

Note: This complete article is in the RMOUG Fall 2015 SQL>UPDATE. The online newsletter can be accessed here.

Honored to be an Oracle Developer Choice Awards – Application Express Finalist

I am honored to be a finalist in the Oracle Database Developer Choice Awards, in the Oracle Application Express category.

I am most impressed with my fellow finalists – amazing devotion to helping the APEX community – and humbled to be included in such a crowd.  Congratulations to all!

Please check out the Oracle Database Developer Choice Awards main page, and check out the finalist in all categories:

Most important – Visit the Developer Choice Awards pages and Vote!

If you have comments to share, there is space to do so here, or on the page for each finalist.

Many thanks to the Developer Choice Awards team ~ I am most grateful and honored by the nomination and finalist status.

My Favorite APEX Applications

I have been fortunate to have clients that allow me to work with Oracle Application Express. Fortunate for them, because the tool enables me to produce production applications faster and lighter-weight (pure HTML, no download, less system-administration overhead, less IT maintenance). Fortunate for me, because I enjoy working with the tool.
In general, I enjoy learning; I enjoy the challenge of a new puzzle, of a new tool to learn the ropes of. I believe APEX is one of those tools where one can do just about whatever one needs with it, by getting a bit clever in telling APEX how to produce a page. The cleverness comes in designing the overall application flow, in designing the APEX page flow, in figuring which components ot use where, and in figuring how best to implement business rules. Yes, in general this is the challenge with any web application written in any tool. With APEX, it’s just a bit more fun.

~ My Favorite Applications

I am happy to have written many APEX applications through the years, but some stand out for various reasons of technical challenge, large or small, and personal interest. The names are modified to protect client interests.

Days at Sea

– A fairly simple APEX app on the surface, this application got DAS calculations correct after several high-visibility failed attempts by other more expensive contractors) and included a flexible, extensible, system to allow the application to declaratively grow and adapt to changing regulations. The PL/SQL behind the scenes and APEX to pull all into simple, maintainable interfaces made for delivery on time. Key factor in this project was the team – 3 persons put their heads together and made it work with APEX. A big win.

Interlab Quality Control

– Consolidation of laboratory statistics into an enterprise database,plus a series of complex quality control statistics, presented in a series of customized reports and charts. Moving this medical corporation’s quality statistics from MS Access/Excel – and awesome app in itself – is a big win for the client. Additional phases in progress and more reports and charts are developed. Hmm. D3 or FOT in the future?
Key fun features: XSL-FO templates for color-coded PDF output that matches the color-coded online interactive reports, some neat data loading challenges, and an automated scatter-plot slide show to replicate (improve on) an in-house quality display.

Proficiency Management

– A system for collection, review, tiered approvals and notification of proficiency management information. Automated data loads, automated notifications and a complex set of business rules made development fun and deployment satisfying.

Critter Information Database

– A true migration from a fully-licensed Discoverer installation to BI in APEX. Still in use today, with another migration of a sister Discoverer installation in progress this year. APEX 5 makes this migration so much easer, and the resulting app will have more BI features at less development cost. Non-confidential and confidential users and authorizations schemes in APEX and in the database structures contorl who sees what. Key fun features: PL.SQL Pivot queries and interface customizations to get a BI “look” to the tool.

Permitting and Landings Applications

– This series of applications, completed over several years, marked migration for Oracle Forms and Reports to APEX, enabling the agencies to retire costly Forms and Reports licenses, streamline deployment (no more Java Applet!) and reduce resource costs for development and maintenace. Now these same agencies are upgrading to mobile application and adding more complex features – a positive example of long-term planning and a successful complete migration to APEX and mobile technologies.

Inspection Database

– A set of two applications, one for automated loading of standards data from various regulating agencies, one for collection, consolidation and edit of inspection reports. Key fun features Online editable “report” to replace MS Word document edits, and XSL-FO templates for PDF version of the final report. Fun in progress on this project!

~ It Takes a Team

It’s not all me ~ every great application has a great team behind it. Along the way I have learned immeasurably from:
– The APEX community – I feel the most open and sharing user community there is,
– The fabulous clients I have worked with (rather than for) through the years, and
– The magnificent managers I have been lucky to have who guided me, challenged me to grow, and had faith in me when I did not have it in myself.

APEX Presentations ~ Through the Years

I was recently asked to summarize my APEX Presentations. I realized I had them in several places, but not in one consolidated space. So here it is – a summary of my APEX Presentations through the years:

APEX 5 Interactive Reports

Updated for the APEX 5 release, these links contain the presentations from KScope 15, and white papers as published in RMOUG’s SQL>UPDATE magazine.

For APEX 5, Interactive Reports have been reengineered from the inside out. Any developer who uses IRs, has made customizations for appearance or features or performance outside of the standard API’s, even pagination plugins, needs to be aware of the new CSS and JavaScript engine.  APEX 4 and earlier customizations will likely not work in APEX 5 without some refactoring. Be prepared!

Presentations: APEX 5 (Released) Interactive Report Deep Dive, KScope 2015 Presentation
   APEX5 Interactive Reports New Features and Upgrade Cheat Sheet – Presentation RMOUG 2015
Papers:     APEX 5 Interactive Reports Part I: New Features and Enhancements
     APEX 5 Interactive Reports Part II: Structural CSS and JS Widget Code Changes
 

Migrating Critical Business Application to APEX – Successfully

Presentation: Migrate Business Applications to APEX, Successfully – Presentation 

I had a blast at COLLABORATE14 in Las Vegas, NV, April 6-11, 2014.  I had a chance to catch up on Oracle 12c skills, learn more about ADF Mobile with APEX for hybrid mobile applications, XQuery and XML DB and of course refresh friendships with all those at IOUG.  My Friday presentation was on Migrating Critical Business Applications to APEX, covering tips and tools for migrating any legacy app to APEX.

APEX Data Load Options, or, How Do I Load Data, Let Me Count the Ways …

Presentations: APEX Data Loading Options

There are many many ways to load data into an Oracle application. This presentation discusses data load methods specific to APEX – the data load wizard, external files, custom methods and using the APEX Listener for a true MS Excel file upload. This is practical what works, what doesn’t information to help one decide the best approach for data loading problems.

Meaningful Maps, Gantts and Charts

Presentations: Meaningful Maps, Gantts and Charts

APEX 4.0 introduces improved charts and maps, but how to make sense of them? This presentation covers all the basics for understanding APEX 4.0 Charts, Maps and Gantt Charts.  Plenty of information to get one building meaningful charts and maps in APEX applications.

Tight Tabular Forms

Presentations: Tight Tabular Forms

APEX tabular forms are handy, but kind of loose, if you use them out of the box. This presentation covers the improvements in APEX 4.0 for tabular form validations, plus some tips on adding validations using the APEX_APPLICATION arrays, and building manual tabular forms using the APEX_ITEM API.

Migrate BI to APEX: What Works, What Doesn’t, and Lessons Learned Along the Way

Presentation: Migrate BI to APEX – What Works, What Doesn’t, and Lessons Learned Along the Way

This presentation covers a real migration from a major-vendor BI tool to APEX Interactive Reports for end-user information needs. Covers feature considerations such as drills, pivots, output; dynamic crosstab options and construction, including use of 11g PIVOT and AMIS PIVOT object type solution.  Careful crosstab query construction makes APEX Interactive Reports more powerful than one may think. APEX 4.0 new features address the needs for user-defined grouping, shared reports, scheduled report delivery, multiple views of the same data set and improved charting.  Check it out!

Note:  I am working on an APEX 5 version of this presentation – improvements in APEX 5 interactive reports, including the PIVOT feature, may tip the scales and make a switch from an expensive, underutilized BI tool to APEX a better use of resources.

Oracle Application Express: Tactics to Tackle APEX Bugs

Paper:               Tactics to Tackle_APEX Bugs,  Paper

Presentation: Tactics to Tackle_APEX Bugs, Powerpoint

Know your application, know your tools, have a plan, and always remember that you know some stuff. You can debug Application Express apps and stay sane.

APEX development is a breeze, until something goes wrong and there’s no obvious clue of what happened or how to fix it, and there’s no UNDO. Or is there? This session presents tactics to tackle common APEX problems such as MRU internal error, Browser errors, SQL and PL/SQL issues, HTML, and JavaScript problems. We cover triage, debug tool options, and debug tactics, and then demonstrate applying those strategies to tackle common APEX problems.

This paper and presentation were written for APEX 4.0 (or earilier?) ~ APEX debugging techniques are much improved now! However, the strategies and tactics for addressing bugs: knowing your app, knowing your tool, instrumenting, researching first and using the forums still apply.

Oracle Application Express Interactive Reports: The Good, The Bad, The Ugly

Presentation: APEX Interactive Reports: The Good, The Bad & The Ugly

Paper:               APEX Interactive Reports: The Good, The Bad, The Ugly

I had fun writing this paper, mainly because the movie (old western, Clint, of course) theme song played in my head, and our house is defnitely a Clint-John Wayne-Sam Elliot-Any Old Western neighborhood.

Oracle APEX Interactive Reports have many Good points, but one-size does not fit all, so we developers still have some cleverness to apply to meet end user requirements in all cases. This paper outlines the Good, the Bad, the limitations, and shows some easy CSS edits to address the Ugly, the default appearance. Have fun!

APEX Interactive Reports offer amazing functionality out-of-the box, but this wealth of features comes with limitations. This session presents the Good, the Bad and the Ugly of APEX IR, then details and demonstrates workarounds to address the Bad (the limitations) and the Ugly (the appearance). Learn how to limit Search and Activity features for different user roles, how to eliminate part or all of the Search and Activity Bars and how to customize the look-and-feel to fit your corporate template.

(As with all my papers, I will keep this post up to date with the latest version of the paper.)

APEX Cheat Sheet

Download the APEX Cheat Sheet paper from here: APEX Cheat Sheet

When starting out with Application Express, it can be a bit confusing in terms of what syntax to use where, how to effect the item alignment needed, how to customize the look-and-feel… in general, how to get productive. Tha APEX Cheat Sheet paper is a collection of tips, how-to’s, syntax conventions and tricks to accelerate a developer’s APEX learning curve. The APEX Cheat Sheet paper has grown to be much longer than a “cheat sheet” but it does provide a solid quick-start to APEX development.

Note: While written for erly APEX versions – APEX 3! – some of the basics still apply, like the f?p syntax.  Someday I will do another Cheat Shet- the problem is there are so many new features, I will have to do multipe cheat sheets for each major feature.

APEX Under the Covers

Paper: APEX Under the Covers

In working with Oracle Application Express I have found the best way to learn “how they did that” is to look “under the covers” at the APEX code … The way to do that is to download an application, install it in my builder, and view how the author implemented the features of interest.

The white paper and presentation APEX Under the Covers walks the reader / viewer through the learning process of looking under the covers at some not-so-standard features implemented in APEX. The examples are not rocket science; they are intended only to get the brain thinking along lines where the reader may not yet have ventured, suggesting a few different approaches to achieving an end within APEX.

Note: This presentation was written for APEX 4, but the approach is the same with APEX 5 and beyond – learn from how they wrote APEX. For APEX 5, use and LOOK AT how they wrote the packaged applications. This is free training at its best!

APEX Debug Options

Paper: APEX Debug Options

Debugging Oracle Application Express can be a conundrum.   It’s PL/SQL, but I cannot see it, and I cannot step through it. PL/SQL generates the page, but I do not have access to the APEX page generator. There is JavaScript and CSS and HTML … Where to start?  The truth is there are many avenues for debugging APEX; some APEX-supplied, some external to APEX. The paper and presentation APEX Debug Options describes both APEX-supplied utilities and tools external to APEX for debugging APEX applications.

~ Keeping it Fresh: Cost-Effective Training

Layoffs, economizing, more for less, and oh-by-the-way keep up with the latest in Web development, languages, data modeling, coding techniques, testing, quality, the latest App Servers and find time to relax a bit and network with your peers. The temptation is to postpone or skip all training. I suggest however that this is the time we need training all the more. I maintain the most cost-effective training can be found at our user group conferences. Attend! Volunteer – get involved! IT is the most efficient, cost-effective way to stay current and learn new technologies, and you might have some fun along the way.

READ_XLSX_for CLOBs ~ Extending Anton’s AS_READ_XLSX for CLOBs

I had a need to read a series of MS Excel XLSX files from a file server over a period of time – usually chunks of 20-50 files, several times a year. That’s too many files to make an upload interface practical (without annoying the users), and the files come as is from an external agency so there is no control over the contents. That is, this is NOT a case of “save to CSV format” – the requirement is to read MS Excel .XLSX format files as they come.

I was happy to use Anton Scheffer’s AS_READ_XLSX code .. but wary of the VARCHAR2(4000) column limit. Sure enough, a few files in, I hit that limit.

What to do? Modify – adjust – Anton’s code to work with CLOBS, of course. The CLOB-ready package is here, PACKAGE_READ_XLSX_CLOB.

So now I have an AS_READ_XLSX_CLOB package that will read the contents of an XLSX file column into a CLOB.

Wh so much data in one MS Excel column? Not my concern – all I need is to be able to read it into my Oracle database.

The adjusted package is available here, PACKAGE_READ_XLSX_CLOB.

The change?  Simple – remove the VARCHAR2(4000) limiting piece – the DBMS_XLSPROCESSOR.VALUEOF function call.

With a little research I discovered the DMBS_XSLPROCESSOR.VALUEOF function was returning into a VARCHAR2(4000) variable  Understandable for a function call.

BUT the DMBS_XLSPROCESSOR.VALUEOF procedure does not have that limit – well, it would have  depending on how I have the variables that hold the VARCHAR2 OUT parameter.  Using the VALUEOF procedure made it easier to use a CLOB variable to accept the OUT parameter.  Of course there is implicit conversion from the procedure VARCHAR2 OUT parameter to the CLOB variable.

I used a CLOB, because that is how I need to store my data. And yes, a significant number of those spreadsheet table cells are indeed > 4000 characters, meriting the CLOB datatype for our purposes

The change:

Change the string_val declaration from VARCHAR2(4000) to CLOB

  type tp_one_cell is record
    ( sheet_nr number(2)
    , sheet_name varchar(4000)
    , row_nr number(10)
    , col_nr number(10)
    , cell varchar2(100)
    , cell_type VARCHAR2(1)
    , string_val clob        --KC: was --varchar2(4000)
    , number_val number
    , date_val date
    , formula varchar2(4000)
  );

Replace the function calls:

t_strings( t_c ) := dbms_xslprocessor.valueof( dbms_xmldom.item( t_nl, i ), '.' );

with equivalent procedure calls:

dbms_xslprocessor.valueof( dbms_xmldom.item( t_nl, i ), '.', t_strings( t_c ) );

Then I use the AS_READ_XLSX_CLOB package the same as AS_READ_XLSX … for example:

select * from table( as_read_xlsx.read( as_read_xlsx.file2blob( 'DOC', 'Book1.xlsx' ) ) );

or, for ease of reading data in a procedure:

CREATE VIEW MYSPREADHSEET_V AS select * from table( as_read_xlsx.read( as_read_xlsx.file2blob( 'DOC', 'Book1.xlsx' ) ) );

and then reading data is as simple as:

SELECT string_val
  FROM MY_SPREADSHEET_V
 WHERE row_nr = 1
   AND col_nr = 2;

and its many variations.

Now I am reading in XLSX spreadsheets with ease, no matter what size.

Thank you Anton ~

SQL Developer Dropping Connections – Solved

I work fast, most often across several database at once, multitasking across projects. Recently with one client I noticed SQL Developer dropping connections, repeatedly, but only on certain database connections. Most often I would need to reconnect upon opening a table or view, package, trigger, almost any object from the navigator. After successfully compiling something, need to reconnect. After creating a trigger, reconnect. Forget about an After-Update trigger – that visibly disconnected me – so I got in the habit of creating things outside of SQL Dev.  Wait a minute..that’s just wrong. I knew this had to be something easy to fix.

That’s when I started looking … After a bit of research I found this link :

Brendan Tierney – Oralytics Blog: SQL Developer is dropping connections

which explained my problem – and offered a solution:

The solution (since that’s what you care about):

Add this line:

AddVMOption -Doracle.net.disableOob=true

to the sqldeveloper.conf file.

I actually added mine to the sqldeveloper_nodebug.conf file.

For SQL Developer 4.1, for my install on Windows 7, this falls in the …\sqldeveloper\bin\ directory for the SQL Developer install directory.

The problem (the short version):

The theory is that this is being caused by and Out of Bands (OOB) error in the jdbc driver or on the network.  Whatever the error, jdbc driver or network, the constant need to reconnect was rendering SQL Developer almost useless for those connections for which this occurred.   It is not doing that any more – Yeah!

I do expect that this option will block times when SQL Dev should disconnect – so I am paying attention and watching for side effects.  So far, so good.  Hope this helps someone else,

Karen

APEX Interactive Reports Part I: – New Features and Enhancements

The purpose of this post series is to help readers learn about APEX 5 IRs, in two parts:
• Part 1 – APEX 5 Interactive Report new and enhanced Action Menu and support features.
• Part 2 – APEX 5 Interactive Report CSS and JavaScript changes, and how these changes impact existing APEX Interactive Reports.
• Part 3 – APEX 5 Interactive Report Settings and Performance – Learn how declarative IR settings manifest in SQL query statement changes that may significantly influence performance. This post, inspired by PEter Raganitch’s KScope 2015 presentation, remoinds developers to be aware of the impact of their selections.

BACKGROUND
Introduced in APEX 3.2, IRs have become the default report option for APEX applications. IRs enable developers to deliver a wealth of end user functionality with a minimum of effort. To build an IR the developer enters a few keystrokes, a base SQL query, some optional declarative settings and voila – the end users gets a fully-operational interactive set of data from which they can apply filters, rearrange columns, highlight, sort, chart, group by and otherwise slice and dice their data.
Note: Most developers and end users are familiar with the search, filter, sort and other interactive features. The paper assumes readers are familiar with pre-APEX 5 IR’s. For those who are not, a full description can be found in this Oracle Technet (OTN) introduction to APEX IRs: http://www.oracle.com/technetwork/testcontent/irrs-083031.html
Every APEX release since 3.2 has added more features, most noticeable in the Action Menu. In addition, many developers have added customizations via CSS to improve appearance, dynamic actions to mimic MS Excel behavior, and otherwise extended standard IR functionality. Developers have made IR customizations through dynamic actions, plugins, JavaScript frameworks and other bits of code to effect the desired changes. In general, we APEX developers can be quite creative in delivering enhanced functionality to our end users!
APEX IR
As usual for a new APEX release, APEX 5 introduces new IR features: new and enhanced Acton Menu features, some cosmetic uplifts and some report management improvements. However, with APEX 5, the major IR changes are behind the scenes – APEX IRs have been rebuilt from the inside out. Both the “inside” changes – the JavaScript engine – and the “outside” changes- CSS classes and Ids – are significant. The important note for developers is that because of this re-architecting, even when developers used the APEX-standard dynamic action or plugin frameworks, if the customization code references the pre-APEX id’s and class elements, the customization code will need to be refactored to upgrade.
Why so many changes, and why such a drastic change? Several reasons. The revised IR code allows for:
• Multiple IRs on one page (perhaps the biggest new feature, to be described in detail in later sections of this paper)
• Modal dialogs
• The Universal Theme and Theme Roller customizations
• APEX overall usability and accessibility
These features, particularly multiple IRs on a single page, were just not possible with the pre-APEX IR architecture. The new code makes sense, when one considers that multiple IRs on a single page was not possible with the legacy IR structure – something had to change. With all of the other IDE and end-user interface changes in APEX 5, the IR changes make sense.
The downside is, developers who have tooled outside of the APEX sandbox must now invest some time in upgrading to the new IR structure and JavaScript. All IR customizations made outside of the standard APIs may not work in APEX 5. Developers who have made such changes will need to refactor their customizations.
The following sections discuss APEX 5 IRs in detail. The KNOW YOUR USERS section applies to all developers. The PAGE DESIGNER section gives an overview of the Page Designer, the new IDE for building APEX apps. The NEW FEATURES section reviews key new features that developers and end users can leverage upon upgrade. In Part 2, the CHANGES section addresses the CSS and JavaScript changes such developers need to know to plan their upgrade to APEX 5.
KNOW YOUR USERS
IRs are very powerful in that they deliver a lot of end user functionality with minimal developer effort. However, it is the developer’s responsibility to maximize IR effectiveness by using the declarative settings to tailor the IR to end user needs. This means the developer needs to be aware of such things as overall security needs, how user use the data set, which Action Menu features should be prohibited or restricted, how much training end users will require, which download options are required, and how users are likely to use Saved reports. It is the developer’s job to prepare and deliver the appropriate IR query and action set to support them.
In short, Know Your Users. Watch what they do, because what they really do is not necessarily what they say the do or need. Deliver the functionality they need, restrict the features they should not have, and ensure the data set they receive is useful to them.
PAGE DESIGNER
Perhaps the most impressive new feature of APEX 5 is the Page Designer, an alternative to the Component View and Tree View modes of APEX development.
The Page Designer is a totally redesigned development environment for building APEX. It allows the developer to stay in “edit mode” in one window while viewing the results of changes in a separate window. This eliminates opening and closing edit dialogs – the Page Designer is always open. This new APEX IDE drastically changes the flow of how one develops in APEX, and in most cases streamlines the process. Before addressing APEX 5 IR new features, it is important to be a bit familiar the Page Designer. Figure 1 illustrates the APEX 5 Page Designer.

Page Designer in APEX 5

Page Designer, the new building interface for APEX 5

Figure 1 – APEX 5 Page Designer

The key features are:
• Left Pane – The Tree pane. This pane contains four views, Rendering, Dynamic Actions, Processing and Shared Components. Each view contains a tree structure of the components of that category on the page, and allows for selection of components and Attributes of those components. Selections here open the corresponding property edit dialogs in the right-pane Property Editor region.
• Center Pane – The Grid Layout pane. This pane is a visual representation of the relative location of components on the page. One can rearrange components on the page by drag and drop of selected elements in this region. One can add components by dragging from the component Gallery at the bottom of the page and dropping onto the layout grid.
• Right Pane – The Property Editor. This is where one edits properties of the components selected in the left, Rendering pane. The same attributes for each component type exists as in earlier APEX versions, this is simply a new interface for editing them.
For a better description of the Page Designer, see the APEX 5 Application Builder User’s Guide, section 2.2.2.1. This is accessible from the Help menu of the APEX 5 Early Adopter.
It is easiest to understand and learn the Page Designer by diving in and working with it. While the Page Designer is a totally new development interface, this author found the transition quite smooth. The most difficult aspect was finding attribute locations in the Property Editor. To assist in this I developed the habit of using the Close All button to reduce the Property Editor to simple list, from which it is easier to find the section of interest.
The other change is operational – one makes changes in the Page Designer, then clicks Save, then Run. Run opens a version of the page in a separate window (or in a separate tab, depending on one’s browser settings. Thus a developer can have the Page Designer, the edit interface, open in one window and the current version of the app open in a different window.

Fig 2 - Page Designer Interactive Report settings

Page Designer, Interactive Report Settings

Figure 2 – APEX 5 Interactive Report Region and Property Editor in Page Designer

Fig. 3 - Action Menu in Page Designer

Fig. 3 – Action Menu in Page Designer

Figure 3 – Action Menu Attributes in Page Designer

Specific to IRs, one needs to be familiar with how the IR properties appear in Page Designer ,to be able to find where to make the appropriate changes. This author found the transition quite easy, though it took a few minutes to acclimate. To get to IR properties, click to open the IR in the Rendering region in the left, Tree pane, or click on the IR region in the center Grid Layout pane. Figure 2 shows the IR Regions and Property Editor in Page Designer. Figure 3 shows the Action Menu Attributes in the Page Designer which displays in the right, property panel.
The recommendation is to spend a few minutes in the Page Designer to become familiar with its operation. Then spend a few moments specifically on an IR. Locate the Columns and Attributes in the Tree panel, then locate the corresponding Property Editors in the right panel. Don’t forget to Save (which the Page Designer will remind you of) and Run, both buttons located at the top right of the page. Also, become familiar with jumping from the Page Designer to your application is a separate page or window.
Note: Developers used to achieve as similar simultaneous builder-app window-mode by running the APEX Builder in one browser (i.e. Chrome) page, and running the application in a different browser (i.e. Friefox) page. There are other ways to achieve the same with virtual server names. We no longer have to do this. In fact, when we do, we then have two Page Designer windows and two app windows – this author found it gets confusing quickly. We still need to test in multiple browsers, but it is no longer essential to use multiple browsers or other tricks to have simultaneous develop and run windows. A big plus!
NEW FEATURES
APEX 5 introduces a new IR look-and-feel, improved usability and accessibility features, new and enhanced Action Menu features. The following sections detail the most notable new features that developers and end users should be aware of.
MODERNIZED INTERFACE
The IR user interface has been updated to be “cleaner” and have “more semantic HTML markup”. The cosmetic changes are in line with the new Universal Theme. APEX 5 IRs are responsive, accessible, and easily customized via Template Options and Theme Roller. All popup windows are now modal. All icons are now scalable vector icons. The colors of the icons and popups will follow that of the theme in use.
Column heading dialogs, shown in Figure 4, are now activated by a click. The edit dialogs of the Control Panel are now improved for easier – fewer clicks – edits. All of these cosmetic and usability improvements are apparent and appreciated after a few minutes of working with an APEX 5 IR.

Fig. 4 - Column Headings

Figure 4 – APEX 5 IR Column Heading Menu

.
FLOATING HEADERS
At last, APEX IRs have declarative “floating headers”, a feature much requested by Microsoft Excel (MS Excel) users. This new feature allows a developer to declare that column headings stay fixed at the top of the Page the top of the Region, or scroll with the data (None) as the user scrolls down the page. Figure 5 illustrates fixed headers – fixed to the page – in action (as best one can in a static page). The headers for both IRs stick to the top of the page as the user scrolls through the IR rows. Figure 6 shows the Fixed To attribute options in the Property Editor, used to set the Fixed To column heading behavior.
Alas, the corresponding Fixed Column feature, another favorite of MS Excel users, is not part of APEX 5.

Fig. 5 - Floating Headers

Fig. 5 – Floating Headers

Figure 5 – Floating Headers (“Fixed Headers”)

Fig. 6 - Fixed Header Attributes

Fig. 6 – Fixed Header Attributes

Figure 6 – Fixed Header Attributes

ENHANCED GROUP BY

The GROUP BY action now allows up to 8 Group By columns. This is 3 more Group By columns that APEX 4.2. The Group By modal dialog is shown in Figure 7. Figure 8 shows access to edit an existing Group By pane and the Group By button to toggle between the Group By pane and other IR views (in this example the main tabular view and a Pivot view).

Fig. 7 - GROUP BY Dialog

Fig. 7 – GROUP BY Dialog

Figure 7 – APEX 5 Group By Dialog

Fig. 8  - GROUP BY Options

Fig. 8 – GROUP BY Options

Figure 8 – Group By Options in APEX 5 IR

As with other optional report views, formatting options on the Group By view are restricted, in this case to Group By and Group By Sort. Figure 9 shows the limited set of format actions for a Pivot report. As always, the Filter (shown), Rows per Page, Flashback, Save Report, Reset, Help and Download options, if declared and authorized, are still available in the Group By report view.

Fig. 9 - Limited Format Options  from GROUP BY View

Fig. 9 – Limited Format Options from GROUP BY View

Figure 9 – Group By Limited Format Options

PIVOT
The PIVOT action is a significant new Action. Anyone who has written the SQL for a pivot query with an indeterminate number of columns knows the value of this new feature – all the heavy lifting of building the Pivot query is done automatically for you. Point, click, Apply, and there is your Pivot report. As a reference, links to some common SQL Pivot query solutions are included in the References session of this paper. The old way of achieving a pivot report will not be discussed here.
Figure 10 illustrates the APEX 5 Pivot dialog. Figure 11 shows a pivot view of an IR. Note the Edit Pivot access to edit the pivot view in the control panel, and that Pivot button for toggle between the Pivot report view and other report views that may be defined.

Fig.10 - Pivot Dialog

Fig.10 – Pivot Dialog

Figure 10 – APEX 5 PIVOT Dialog

Fig. 11 - PIVOT Options

Fig. 11 – PIVOT Options

Figure 11 – APEX 5 IR PIVOT Options

As with other optional report views, formatting options on the Pivot view are restricted, in this case to Pivot and Pivot Sort. Figure 12 shows the limited set of format actions for a Pivot report. As always, the Filter, Rows per Page, Flashback, Save Report, Reset, Help and Download options, if declared and authorized, are still available in the Pivot view.

Fig. 12 - Limited Format Options in PIVOT View

Fig. 12 – Limited Format Options in PIVOT View

Figure 12 – Limited Format actions in Pivot view

MULTIPLE IRS
Developers may now build “any number” of IRs on one page. This single feature is one of the reasons for the changes in how IR elements are named, – it was essential to do so, so that each IR element is clearly identified. To create multiple IRs on one page, simply create another one using any of the Create Region options. The Create IR wizard used to block this operation – that block has been removed. Create away!
With the improved editing capabilities of the Page Designer, it is easier than ever to create multiple IRs on a single page, as it is very simple to copy (Duplicate) and move regions around on the page.
To copy an IR on the same page, from the Rendering view in the Tree pane, right-click the IR region to copy and then select the Duplicate option. If the new, duplicate region was not created where you want it, select the IR in the Grid Layout pane and start to move it. The objects in the Grid Layout pane will become highlighted in yellow – this indicates you are in the drag-and-drop mode that allows you to drag the selected region to a new location. Drag the selected region around to the desired location and let go.
Hint: You may have to go slow, and be patient with getting the drag-and-drop layout to open up the location you want. Figure 13 shows selection of the Duplicate option from the Rendering pane.

Fig. 13 Duplicate Region Options

Fig. 13 Duplicate Region Options

Figure 13 – Duplicate Region Option from the Rendering Pane

LINKING
Allowing multiple IRs on one page mandates changes in how filter parameters are passed to an IR in links between pages. The traditional IR filter options of IREQ_<COLUMN_NAME>, etc. shown in Table 1 work for a single IR on a page and will continue to work for the case of a single IR on a page. Applications with links to pages that contain one IR will continue to work upon upgrading to APEX 5. When there are multiple IRs on a page, however, this link syntax changes.

APEX Single IR Link Qualifiers
Single IR Link Qualifier Meaning
IREQ_<column_alias> Equals
IR _<column_alias> Equals
IRLT_<column_alias> <
IRLTE_<column_alias> <=
IRGT_<column_alias> >=
IRGTE_<column_alias> >=
IRLIKE_<column_alias> LIKE
IRN_<column_alias> NULL
IRNN_<column_alias> NOT NULL
IRC_<column_alias> Contains
IRNC_<column_alias> NOT Contains

Note, no BETWEEN, IN and NOT IN options
Table 1 – Single IR Link Filter Syntax

With multiple IRs on a page, the link syntax must distinguish which IR to operate on. To do so, the APEX 5 link syntax for cases of multiple-IRs incorporates the Static Id of the IR, in square brackets, just after the link qualifier:

IREQ[STATIC_ID]_<COLUMN_NAME>

The full list is the same as for single IRs, as shown in Table 2.

Table 2: APEX Multiple IR Link Qualifiers
Multiple IR Link Qualifier Meaning
IREQ[STATIC_ID]_<column_alias> Equals
IR_[STATIC_ID]<column_alias> Equals
IRLT[STATIC_ID]_<column_alias> <
IRLTE[STATIC_ID]_<column_alias> <=
IRGT[STATIC_ID]_<column_alias> >=
IRGTE[STATIC_ID]_<column_alias> >=
IRLIKE[STATIC_ID]_<column_alias> LIKE
IRN[STATIC_ID]_<column_alias> NULL
IRNN[STATIC_ID]_<column_alias> NOT NULL
IRC[STATIC_ID]_<column_alias> Contains
IRNC[STATIC_ID]_<column_alias> NOT Contains

Note, no BETWEEN, IN and NOT IN options

To facilitate passing parameters, it is recommended that the developer declare a Static Id for the IR. If a Static Id is not declared, one will be generated for you in the format R123456789012345 wher 1234567890125 is th assigned static identifier. For this author, it is much easier to remember and use a declared Static Id (one that I define) than to use Inspect Element to dig out the APEX-supplied region identifier. It is simpler and more meaningful to pass references of the format IREQ[EMPS]_DEPTNO, for example, than write references such as IREQ[R1132354054905]_DEPTNO.
WHY MULTIPLE IRS?
One may ask, what is the value of multiple IRs on the same page? The use cases are as many and varied as there are APEX installations. The fact is, users are accustomed to search and filter operations on the report, they want and even expect those features on all of their reports. It is likely when there are multiple IRs on one page the span of actions allowed in each IR will be limited to those that make sense for the particular data set.
It is the developer’s responsibility to design the page and the IRs on it such that the user has exactly the functionality they need, and is not overwhelmed with options.
POSSIBILITIES
Multiple IRs on one page opens up several options not previously possible. Consider building a dashboard of reports, all IRs so that each data set may be configured with chart, group by and perhaps pivot views. Imagine driving the contents of all the IRs with a click on the value of one IR, say, the one in the top left position. Figure 14 illustrates such a scenario.

Fig. 14 - Multiple IRFigure 14 – Multiple IR “Dashboard”

This scenario can be constructed by building multiple IRs on one page, then enabling a link on the Dept column of the top left IR to the DEPTNO columns of the remaining IRs on the page. To do this, edit the Link attribute of the DEPT column of the top left IR, as in Figure 15. The Link attributes region may not readily appear in the column property editor. If it does not, ensure that the column type (at the top of the Attributes panel) is selected as Link. Then the Link attributes region should appear as shown in Figure 15.

Figure 15 - IR Column Link Syntax

Figure 15 – IR Column Link Syntax

Figure 15 – IR Column Link Property Editor

The Link attributes region may not readily appear in the column property editor. If it does not, ensure that the column type (at the top of the Attributes panel) is selected as Link. Then the Link attributes region should appear as shown in Figure 15.

Fig. 6 - Component View from Page Designer

Fig. 6 – Component View from Page Designer

Figure 16 – Component View Icon from Page Designer

An alternative way to set the Link attributes is to revert to the Component Editor, add the column link attributes there, then return to the Page Designer. The column Link attribute section will be there. The Component View can be reached by click on the Component View icon, shown in Figure 16, in the Page Designer top menu.
To return to the Page Designer from Component View use the corresponding Page Designer icon in the top menu bar, as shown in Figure 17.

Fig. 17 - Page Designer from Component View

Fig. 17 – Page Designer from Component View

This same approach of switching to the Component View to perform certain settings, then switching back to Page Designer, is always available and can be helpful during a developer’s transition to to being fully comfortable in Page Designer
CLEAR AND RESET
As with all links to IRs, it is often desirable or necessary to reset the IR to its original or default settings before passing in the next link. There are two options to do this, passed in the Cache position of the APEX URL:
RIR – Resets the IR to the default settings. This is the most frequently used option.
CIR – Clears all IR settings, regardless of the defaults.
A Reset after a Clear will return the IR to its default settings.
A plain RIR or CIR will reset or clear a single IR on a page.
This same syntax will also reset or clear ALL IRs on a page. For example:
f?p=100:10:3629280452177::NO:RIR
will redirect to page 10 of application 100, no debug, resetting the single IR – or all IRs on the page – to the default settings.
To reset or clear only one IR when there are multiple IRs on a page, the syntax is a bit more complicated. The trick is to specify which IR you focusing on using the format IR[STATIC ID] in the Request portion of the APEX URL, followed by the RIR or CIR directive in the Cache portion of the URL. For example:
f?p=100:10:3629280452177:IR[DEPT],IR[EMP]::RIR
Where one IR’s static id is DEPT, and another IRs static id is EMP, this will redirect to page 10 in application 100, reset the IRs with the DEPT and EMP static ids, but will not touch other IRs on the page.
Note that the expected syntax options of [STATIC_ID]RIR and RIR[STATIC_ID] in the Cache portion of the APEX URL do not work. The direction on which IR to operate on must be specified in the Request portion of the APEX URL.
There is always the option to use the APEX_IR API, the CLEAR_REPORT and RESET_REPORT procedures (either signature) in a dynamic action to achieve the desired individual report reset. There is also the option of triggering the APEX-standard apexrefresh event, as described in this article: http://docs.oracle.com/cd/E59726_01/doc.50/e39147/extend_app002.htm#HTMDB30267
Using a command like:
apex.eventtrigger( “#myRegionStaticId”, “apexrefresh”);
All of the Reset and Clear options described in this section are supported.

PART 1 SUMMARY
APEX 5 IRs contain some noteworthy new features for end users and developers. For end users, the most significant of those are the improved look-and-feel, modal dialogs, the enhanced GROUP BY action, the new PIVOT action, and the option for multiple IRs on a single page. For developers, the big new operational change is the Page Designer. This installment covers the highlights of those new and enhanced features.
In Part 2 of this series, we cover the most significant change for developers, the totally revamped APEX 5 IR underlying architecture. Developers who have done customizations on IRs in previous APEX versions may need to refactor their code to follow the new APEX 5 IR structure. With APEX 5, the overall power of APEX IRs has increased, but when it comes to customizations, some upgrade work may be necessary. Stay tuned for Part 2!
REFERENCES
The APEX OTN Forum

APEX Interactive Report OBE’s

AMIS Pivot Implementation for pre APEX 5

Manually Refreshing APEX Components

APEX 5.0 Interactive Report Customization, John Snyders