Tuesday, August 25, 2009

Application Express 3.2.1 patch set applied to apex.oracle.com

This past weekend, the forthcoming Application Express 3.2.1 patch set was applied to apex.oracle.com (and apex.oraclecorp.com, if you're an Oracle employee and user of the internal instance). The APEX 3.2.1 Patch Set Note lists the bugs fixed in this patch set.

In addition to the bugs fixed in this patch set, a few interesting points:

  1. The online help (the popup window of the brows-able documentation) is available in Japanese.
  2. AnyChart AnyGantt Flash Gantt and AnyChart AnyMap files are included in this patch set. Even though these aren't directly integrated into the Application Express declarative environment, they are included in the license of Application Express and available for your use within an Application Express application.
  3. An updated version of FCKEditor is included, fixing a number of bugs. However, one user has already reported a change in behavior, with the default behavior of the Enter key resulting in a '<p>' versus the previous '<br />'.
  4. This version of Application Express, 3.2.1.00.10, is the identical version that will be bundled with Oracle Database 11gR2.

For those customers running Oracle Database 11gR1 11.1.0.7, you'll need to pay special attention to the note about applying the APEX 3.2.1 patch set.

As with all past Application Express patch sets, the Application Express 3.2.1 patch set will be available for download on Oracle MetaLink. The full distribution of APEX 3.2.1 will be available for download on OTN. These should be available within one day.

Thursday, August 20, 2009

Neues Application Express Buch - auf Deutsch!

Im November 2009 soll das neue Buch "Oracle APEX und XE in der Praxis" von Dietmar Aust, Denes Kubicek und Jens-Christian Pokolm herauskommen. Ich kenne Dietmar schon seit den Anfangstagen der Oracle XE Datenbank, wo er innerhalb kurzer Zeit ein Experte für diese wurde. Und Denes Kubicek ist ein bekannter Experte für Oracle Application Express, welcher letztes Jahr mit dem "Oracle APEX Developer of the Year" ausgezeichnet wurde.

Ich freue mich schon auf das Buch (und natürlich auch auf eine signierte Ausgabe des Buches!).

--------

Coming in November 2009 is a new book from Dietmar Aust, Denes Kubicek and Jens-Christian Pokolm, entitled "Oracle APEX und XE in der Praxis". I have known Dietmar since the early days of Oracle Database XE, where he quickly became a subject matter expert. And Denes Kubicek is a recognized expert of Oracle Application Express and was last year's Oracle APEX Developer of the Year.

I look forward to this book (and getting a signed copy of this book!).

Forthcoming book about Application Express

Today, Packt Publishing announced their forthcoming book, "Oracle Application Express 3.2 – The Essentials and More", authored by my good friend Arie Geller and Matthew Lyon. The expected availability is January 2010.

Congratulations, Arie. The end is in sight!

Thursday, August 13, 2009

Application Express & YubiKey

Roger Cohen from APEXtras was kind enough to introduce me to two-factor authentication using YubiKey and Application Express.

Now - I'll be honest, I had never heard of YubiKey before, but I am familiar with two-factor authentication. I am a satisfied user of KeePass, and I am able to maintain both a password and a separate key file (in my case, on a Flash Drive) for access to my encrypted KeePass passwords database. I need both my password and the keyfile to access the passwords database. I lose one or both and I can't get in.

Roger gives a very good description of YubiKey here, what it's good for and why you would want to consider it. But more importantly, Roger has a working demonstration of APEX and YubiKey authentication live on apex.oracle.com. Granted, you'll need a YubiKey for this demonstration to work. Lastly, the folks from APEXtras were kind enough to post an explanation of the logic and all of the source code for the custom authentication for this solution.

Wednesday, August 12, 2009

Oracle Database Resource Manager and Oracle Application Express

At ODTUG Kaleidoscope this year, I gave a presentation on using the Oracle Database Resource Manager with Oracle Application Express. The Oracle Database Resource Manager enables an administrator to control the allocation of hardware resources within an Oracle database - something that an OS-based process scheduler cannot accomplish. The actual PowerPoint presentation is here.

I often talk about the scalability of Oracle Application Express on apex.oracle.com, which runs on fairly modest hardware. However, I fully believe that this database and server would eventually crumble if it were not for our use of the Oracle Database Resource Manager. Unlike a database instance which is running a handful of tuned applications, apex.oracle.com is a free-for-all. As long as you have a workspace, you can run whatever SQL you like from SQL Commands (I'm not recommending this), or, you could inadvertently write some pretty inefficient SQL or PL/SQL in your application. Without any controls in place, a user could easily and quickly monopolize the CPU resources on apex.oracle.com. And for a site that gets between 3.5 million and 6 million page views per week, page view requests could quickly back up and overwhelm the database server.

So how do we manage this chaos? Via the Oracle Database Resource Manager. Rather than explain the syntax of the Resource Manager, I think it's much simpler to convey the plan that is in place right now on apex.oracle.com and then comment on it.


-- apex.oracle.com resource plan

-- Section 1
begin
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();

dbms_resource_manager.create_consumer_group(
consumer_group => 'APEX_HIGH',
comment => 'All APEX sessions start in this group.');
dbms_resource_manager.create_consumer_group(
consumer_group => 'APEX_MEDIUM',
comment => 'APEX sessions are switched to this group after 10 seconds.');
dbms_resource_manager.create_consumer_group(
consumer_group => 'APEX_LOW',
comment => 'Any sessions in this group have been executing for more than 120 seconds');

dbms_resource_manager.submit_pending_area();

end;
/


-- Section 2
begin
dbms_resource_manager_privs.grant_switch_consumer_group (
grantee_name => 'APEX_PUBLIC_USER',
consumer_group => 'APEX_HIGH',
grant_option => FALSE );
dbms_resource_manager_privs.grant_switch_consumer_group (
grantee_name => 'APEX_PUBLIC_USER',
consumer_group => 'APEX_MEDIUM',
grant_option => FALSE );
dbms_resource_manager_privs.grant_switch_consumer_group (
grantee_name => 'APEX_PUBLIC_USER',
consumer_group => 'APEX_LOW',
grant_option => FALSE );
end;
/

begin
-- Section 3
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.create_plan( plan => 'APEX_ORACLE_COM_PLAN', comment => 'APEX Plan');



-- Plan Directives Section
dbms_resource_manager.create_plan_directive(
plan => 'APEX_ORACLE_COM_PLAN',
group_or_subplan => 'APEX_HIGH',
comment => 'All APEX sessions start in this group.',
mgmt_p1 => 70,
switch_group => 'APEX_MEDIUM',
switch_time => 10,
switch_for_call => TRUE,
switch_estimate => FALSE );

dbms_resource_manager.create_plan_directive(
plan => 'APEX_ORACLE_COM_PLAN',
group_or_subplan => 'APEX_MEDIUM',
comment => 'APEX sessions are switched to this group after 10 seconds.',
mgmt_p1 => 8,
switch_group => 'APEX_LOW',
switch_time => 120,
switch_for_call => TRUE,
switch_estimate => FALSE );



dbms_resource_manager.create_plan_directive(
plan=> 'APEX_ORACLE_COM_PLAN',
group_or_subplan => 'APEX_LOW',
comment => 'Any sessions in this group have been executing for more than 120 seconds',
mgmt_p1 => 2,
switch_group => 'CANCEL_SQL',
switch_time => 1800,
switch_for_call => TRUE,
switch_estimate => FALSE );


-- Section 4
dbms_resource_manager.create_plan_directive(
plan=> 'APEX_ORACLE_COM_PLAN',
group_or_subplan => 'OTHER_GROUPS',
comment => 'The mandatory group',
mgmt_p1 =>10);

dbms_resource_manager.create_plan_directive(
plan=> 'APEX_ORACLE_COM_PLAN',
group_or_subplan => 'ORA$AUTOTASK_SUB_PLAN',
comment => 'Sub plan for maintenance activity',
mgmt_p1 => 10 );

-- Section 5
dbms_resource_manager.set_initial_consumer_group(
user => 'APEX_PUBLIC_USER',
consumer_group => 'APEX_HIGH');

dbms_resource_manager.submit_pending_area();

end;
/



-- Section 6
begin
dbms_scheduler.set_attribute( name => 'MONDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
dbms_scheduler.set_attribute( name => 'TUESDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
dbms_scheduler.set_attribute( name => 'WEDNESDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
dbms_scheduler.set_attribute( name => 'THURSDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
dbms_scheduler.set_attribute( name => 'FRIDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
dbms_scheduler.set_attribute( name => 'SATURDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
dbms_scheduler.set_attribute( name => 'SUNDAY_WINDOW',
attribute => 'RESOURCE_PLAN', value => 'APEX_ORACLE_COM_PLAN');
end;
/


-- Section 7
alter system set resource_manager_plan = 'APEX_ORACLE_COM_PLAN' scope=both;




  • Section 1 - Create three consumer groups with the names APEX_HIGH, APEX_MEDIUM and APEX_LOW. These group names are arbitrary. A consumer group is simply a collection of users.

  • Section 2 - Remember that the Oracle HTTP Server and mod_plsql connect to the database as user APEX_PUBLIC_USER (if you're using the embedded PL/SQL Gateway, this is user ANONYMOUS). From a database perspective, all it sees are a bunch of database sessions, connecting as database user APEX_PUBLIC_USER. So in Section 2, we are granting the ability to switch among these consumer groups to database user APEX_PUBLIC_USER.

  • Section 3 - Create the plan directives which controls how much of the machine resources is dedicated to a particular consumer group, and how long they are allowed to remain in this group before switching to another group. So if a session is in the APEX_HIGH group, the APEX_HIGH group is entitled to 70% of the CPU resources. If the top-level SQL call is executing for more than 10 "on-CPU" seconds, then they get switched to the APEX_MEDIUM group. The APEX_MEDIUM group gets only 8% of the available CPU resources, for up to 120 seconds. After 120 seconds, the session gets switched to the APEX_LOW group. The APEX_LOW group has only 2% of the CPU resources available. After 1800 seconds (which is a *long* time), if the top-level SQL call is still executing, then it will be canceled. The session will not be killed, but the top-level SQL call will be canceled.

  • Section 4 - Directives are created for two other pre-defined and built-in groups, namely, OTHER_GROUPS and ORA$AUTOTASK_SUB_PLAN. The ORA$AUTOTASK_SUB_PLAN is used for all of the automated maintenance tasks of the database (e.g., statistics collection). OTHER_GROUPS is used for any other session not already a part of a group in the active Resource Manager plan. This would be the group for anyone connecting directly to the database, background database jobs not running as APEX_PUBLIC_USER, etc.

  • Section 5 - Make APEX_HIGH, our newly created consumer group, the default consumer group for user APEX_PUBLIC_USER. Then, submit the pending area for validation.

  • Section 6 - The Oracle database (at least for 11gR1 and 11gR2) ships with a predefined scheduler plan for maintenance tasks. Modify the resource plan in effect during these maintenance windows. If we don't, then the DEFAULT_MAINTENANCE_PLAN would be in effect and not our newly created Resource Manager Plan APEX_ORACLE_COM_PLAN. And what that means is we'd be back to a free-for-all during this maintenance window, with anyone being able to monopolize the server.

  • Section 7 - Change the settings of the database to use our newly created plan.





There are tools available in Enterprise Manager to create and monitor resource plans, so you don't have to commit the syntax of all of these PL/SQL packages to memory. Also, there are a large number of database views that can be used to monitor the Resource Manager, including:


  • V$RSRC_PLAN – Currently active resource plan

  • V$RSRC_CONSUMER_GROUP – Cumulative amount of CPU stats

  • V$RSRC_PLAN_HISTORY – History of resource plan, when enabled, disabled or modified

  • V$RSRC_CONS_GROUP_HISTORY – History of consumer group statistics

  • V$RSRCMGRMETRIC – Information about resources consumed and wait times per consumer group

  • V$RSRCMGRMETRIC_HISTORY – History of Resource Manager metrics




I granted privileges on these SYS-owned views to another database user that was mapped to an APEX workspace (actually, my workspace on apex.oracle.com). Then, I was able to easily build an APEX application using Interactive Reports on top of these views and monitor how well we were doing.

The Oracle Database Resource Manager is only available as a part of the Oracle Database Enterprise Edition. It is not available with XE, Standard Edition One, or Standard Edition of the Oracle Database. But for those customers that are already using Oracle Application Express on the Oracle Database Enterprise Edition, and they're attempting to consolidate a number of groups and applications onto a single instance, the Oracle Database Resource Manager can be easily used to prevent any one user or application from monopolizing the server.

Tuesday, June 09, 2009

Who says Application Express can't scale?

Over a year ago, I wrote about who is using Oracle Application Express on http://apex.oracle.com. At the time, I included some weekly statistics.

During our team meetings every week, I report on the overall usage of http://apex.oracle.com. I just wanted to report on some astounding numbers:


Total Page Views Distinct Applications Distinct Users
---------------- --------------------- --------------
6225566 3268 2778


Total Workspaces
----------------
11643


Total Applications
------------------
39849


Workspaces Approved
-------------------
316

That's 6,225,566 page views in the past week, and this is still running on the same Dell PowerEdge 1950.

Now granted - the ability to sustain this type of load throughout the week deserves some credit to Kris Rice, who spent a fair amount of time analyzing Application Express on apex.oracle.com and identifying some major problem areas in performance. As well, he brought in some experts to perform OS tuning. The recent purge on apex.oracle.com removed close to 10,000 workspaces, schemas, tablespaces and datafiles. Lastly, a couple months ago, I implemented a Resource Manager plan which prevents someone from monopolizing the entire server. I'll be presenting a detailed discussion of Resource Manager and apex.oracle.com at ODTUG Kaleidoscope 2009.

A large number of these page views are from the bots of Search Engines, especially since ProMED Mail is run on apex.oracle.com. But a page view and execution of the engine is a page view and execution of the engine. All in all, that's a large load on a relatively cheap piece of hardware.

Tuesday, June 02, 2009

OraTweet - Micro-blogging with Oracle Application Express

About a year ago, Carl Backstrom was telling me how he was helping another gentleman in Oracle, Noel Portugal from the CRM On Demand team, with a micro-blogging site developed with Oracle Application Express. Carl game me a demonstration of OraTweet, tried to explain Twitter, tweets, and micro-blogging. I just didn't get it, at the time.

Today, micro-blogging appears to be all the rage. Dwight Howard from the Orlando Magic basketball team is on Twitter. CNBC's Fast Money television show is on Twitter. I am even on Twitter, but I really don't use it, as you can tell.

Noel's application, OraTweet, has been in use within Oracle for the past year. As Noel states on the oratweet.com site: "Teams around Oracle are finding ways to communicate with their teams while reducing email overload. The results have been amazing. Global team members are connecting and sharing information. Users have started to develop stand alone clients to consume OraTweet’s timeline. We have also integrated the OraTweet timeline to Oracle Connect, our own internal social network. Overall information is flowing faster in a lightweight format."

Noel Portugal has developed an excellent Web site which explains OraTweet, lets you submit feedback, and provides a link to download the entire source code for OraTweet: http://oratweet.com/

Friday, May 29, 2009

See you in Monterey?


Time is running out for the Oracle Development Tools User Group Kaleidoscope Conference in Monterey, California on 21-June-2009 through 25-June-2009. The lower cost advanced registration ends next Tuesday, 02-June-2009. The folks from ODTUG were kind enough to provide a template to use for a justification letter for your employer.

It all begins with the Application Express Symposium on Sunday, of which over 160 people are registered. Other than the opening remarks by some joker from Oracle, all other presentations at the Symposium are from customers and the community. And then there is a full agenda for the remainder of the week if you're interested in Oracle Application Express.

This is an outstanding, well-organized and well-run conference, giving customers the opportunity to interact with some of the greatest Application Express experts from around the world. This is a conference where you can listen, learn and discuss the solutions created by successful Oracle customers. Oracle is invited to participate, but this conference is run by ODTUG.

Disclaimer: I am not associated with this user group nor is there any financial incentive to me for the number of people in attendance.

Monday, April 20, 2009

Oracle Single Sign-On and apex.oracle.com

Application Express on apex.oracle.com is now registered as a Partner Application for Oracle Single Sign-On. This means that you can now create demonstration and sample applications, hosted on apex.oracle.com, and have the users authenticate via the Oracle Single Sign-On Login Server.

Who is registered on Oracle.com? Well, if you have ever asked or answered a question on the wildly popular Oracle Application Express discussion forum on OTN, then you already have an account.

To enable SSO authentication to Oracle.com in your application on apex.oracle.com, simply follow these steps:

  1. Shared Components -> Authentication Schemes
  2. Click Create button
  3. Choose “Based on a pre-configured scheme from the gallery” and click Next
  4. Choose “Oracle Application Server Single Sign-On (Application Express Engine as Partner App)” and click Next
  5. Give it a name like SSO and click Create Scheme
  6. In the subsequent report of authentication schemes, click the “make current” link for your newly created SSO one
  7. Click the Make Current button on the confirmation page
  8. Go get a beer (or coffee or tea) to celebrate
It's that simple.

To see this in action, here's a very brief sample application with a public and non-public page, using SSO authentication.

Important note:  As of August 2012, SSO is no longer available on apex.oracle.com.

Wednesday, April 08, 2009

Cleaning Up

The architecture of Application Express is such that the database objects associated with a specific release all exist in a single schema. For the original Oracle HTML DB 1.5, all of the database objects existed in schema FLOWS_010500. As of the most recent version, Oracle Application Express 3.2, all of the database objects reside in schema APEX_030200.

When a new version of Application Express is installed, the following three actions take place:

  1. The new version is installed into a new schema (this happens the same whether it's a new installation or an upgrade installation).
  2. The meta data from the previous version is copied and sometimes transformed into the new schema.
  3. All of the public synonyms which were pointing at the "old" version are now redirected to the new version of Application Express.

The beauty of this architecture is if an error occurs during installation or during upgrade, it's easy to revert back to the previous installation, as documented here. Both an APEX 3.1 installation (in FLOWS_030100) and an APEX 3.2 installation (in APEX_030200) can exist in the Oracle database at the same time, and with only one version active. Understand, though, if you choose to rollback and remove the newer version of Application Express, all of the changes made in the newer version (instance settings, application changes, new workspaces, etc.) will not be propagated back to the old version of Application Express if you switch schemas.

Once you have successfully upgraded your instance of Application Express, tested all of the upgraded applications, and deem the upgrade successful, there is no reason to maintain the old version of Application Express. Not only does it take up space in your database, it leaves a fairly privileged database account in the database, and this could pose a security risk if compromised.

For apex.oracle.com, which currently has over 20,000 workspaces, I always install the new version of Application Express into it's own tablespace. I do not install Application Express into the default SYSAUX tablespace. Application Express 3.1 was installed into tablespace APEX_REL31. When I recently upgraded to Application Express 3.2, and after we ran successfully for a couple days, it was easy to clean up the old Application Express 3.1 by issuing:

DROP USER FLOWS_030100 CASCADE;
DROP TABLESPACE APEX_REL31 INCLUDING CONTENTS AND DATAFILES;

That's it! The privileged database user from the previous version is gone. All of the space on disk is reclaimed. And the newer version of Application Express 3.2 in APEX_030200 hums along just fine.


Note: There is one schema installed with Application Express, FLOWS_FILES, which persists across version upgrades. The sole purpose of this schema is to maintain uploaded files. You should never manually remove this schema unless you want to remove every facet of Oracle Application Express from your database. And if you really wanted to remove every trace of Application Express, I'd recommend using the apxremov.sql script anyway.



Considerations when dropping on Database 11g

If you're using Application Express with Oracle Database 11g (11.1.0.6 or greater), undoubtedly you had to enable Network Services so Application Express could send e-mail, use Web Services, etc. If you didn't do this, then you'll encounter errors like "ORA-24247: network access denied by access control list (ACL)" when APEX attempts to send e-mail or access any other network resource.

One important caveat to the instructions above - if you created an ACL for FLOWS_030100 (Application Express 3.1) and granted connect privileges to FLOWS_030100, after you upgrade to Application Express 3.2 , grant these same connect privileges on the existing ACL to APEX_030200, and you drop database user FLOWS_030100, the Network ACL will contain a dangling reference to FLOWS_030100 and will be invalid. What this means is that if you're running along just fine with an upgraded Application Express 3.2 and you drop FLOWS_030100, your delivery of e-mail may no longer work. Users will see error messages like "ORA-24247: network access denied by access control list (ACL)" in APEX_MAIL_LOG.MAIL_SEND_ERROR.

This situation happened to me over the weekend. After Application Express 3.2 was running for a month on our internal instance, the old FLOWS_030100 database user was finally dropped. Numerous issues were raised on Monday morning by workspace owners who said they could no longer send e-mail and they were seeing the error message "ORA-24247: network access denied by access control list (ACL)" in APEX_MAIL_LOG.MAIL_SEND_ERROR.

The only way I've discovered to rectify this situation is to manually drop the ACL reference to FLOWS_030100. I connected as SYS in SQL*Plus and ran:

exec dbms_network_acl_admin.delete_privilege('power_users.xml','FLOWS_030100',TRUE,'connect');


This underlying database issue, with the ACL privileges not being dropped when a database user is dropped, was filed as Bug 7493477 and is targeted to be fixed in Database 11gR2.

Friday, March 06, 2009

Oracle Application Express in the cloud

You may have heard a thing or two about cloud computing. Jason Straub, from the Oracle Application Express development team, recently blogged about using Oracle Application Express in the cloud - and how you can run APEX in the cloud for as cheap as 20 cents USD / hour.

http://jastraub.blogspot.com/2009/03/test-drive-oracle-application-express.html

There's a little bit of setup to use the Amazon.com Elastic Compute Cloud, but once that's behind you, you can easily stand up your own Oracle database in the cloud for a tiny amount of money. And, in my opinion, this just further demonstrates how the browser-based Oracle Application Express hosted development and deployment environment is so well suited to cloud computing.

Friday, February 27, 2009

Oracle Application Express 3.2 released

Today, Oracle Application Express 3.2 was made available for download off of the Oracle Technology Network.

If you go to http://apex.oracle.com, you'll find links to:

  1. The link to download Oracle Application Express 3.2
  2. The list of new features in Oracle Application Express 3.2
  3. New Oracle By Examples, including a an Oracle Forms to Oracle APEX OBE and a soon-to-be-released security OBE.

Thanks to the Oracle Application Express community for your continued support, ideas and enthusiasm.

Friday, February 20, 2009

Make all of your APEX applications run a bit faster

See the important update below

Interested in making your APEX applications run faster? I know this seems like an impossible and astonishing feat, and you'll soon be approaching page view execution times of zero, but you can squeeze even a little more throughput and scalability with this one small exercise. And this shouldn't cost you an extra cent.

As a lot of people know already, Oracle Application Express is essentially one big SQL and PL/SQL program. "Porting" of Oracle Application Express to other platforms is not necessary. It installs via SQL*Plus. It runs where PL/SQL does. And PL/SQL, truly, is a write-once-run-everywhere platform.

So how do you make a PL/SQL program run faster? Through native compilation of PL/SQL, of course. When you compile a module in PL/SQL, you are converting it to an intermediate form named system code (or bytecode). At runtime, this system code is interpreted. Execution of this program would be much faster if it were compiled natively and the interpretation step was bypassed altogether. This is analogous to the old days of taking an interpreted BASIC program and compiling it to a native program.

An excellent description of PL/SQL native compilation can be found in Oracle Database PL/SQL Language Reference. When PL/SQL native compilation was introduced in Oracle Database 9iR1 and 9iR2, I found it to be complicated and involved, and I think I was successful getting a small program to ncomp once (and only once). Here is the explanation from some poor guy who figured out all the steps to do this in 9iR2 on Windows. But in Oracle Database 11gR1, this is downright trivial.

My test below was done in an Oracle Database 11gR1 11.1.0.6 on Oracle Enterprise Linux on VMWare Server on a Windows Vista x-64 host. With all those layers of software, the performance difference at runtime could still be easily observed. Also, I did this with the soon-to-be-released Application Express 3.2. Wherever you see APEX_030200, replace it with the database user of your specific APEX release (e.g., APEX 3.1 = FLOWS_030100).

The database view DBA_PLSQL_OBJECT_SETTINGS provides information about the compiler settings for all stored objects in the database. Connect as SYS via SQL*Plus or SQL Developer and run the following query (remembering again to replace 'APEX_030200' if you're not running Application Express 3.2):

column plsql_optimize_level format 999
column plsql_code_type format a20
select count(*), o.object_type, s.plsql_optimize_level, s.plsql_code_type
from dba_objects o, dba_plsql_object_settings s
where o.object_name = s.name
and o.owner = 'APEX_030200'
and s.owner = o.owner
group by o.object_type, s.plsql_optimize_level, s.plsql_code_type
order by 2 asc


On my instance this returned:


COUNT(*) OBJECT_TYPE PLSQL_OPTIMIZE_LEVEL PLSQL_CODE_TYPE
---------- ------------------- -------------------- --------------------
12 FUNCTION 2 INTERPRETED
370 PACKAGE 2 INTERPRETED
362 PACKAGE BODY 2 INTERPRETED
19 PROCEDURE 2 INTERPRETED
1 TABLE 2 INTERPRETED
366 TRIGGER 2 INTERPRETED
4 TYPE 2 INTERPRETED

7 rows selected.


All PL/SQL objects are interpreted and have a PL/SQL optimization level of 2. You can alter the PL/SQL compiler optimization level via PLSQL_OPTIMIZER_LEVEL, but I encountered runtime errors in Application Express when I natively compiled with an optimizer level of 3. I don't know why, but I'm saving that for another day.

Recompiling all of these objects via native compilation can be done with three easy statements. Note: You should not do this while the APEX applications are actively being used, as these steps will recompile all of the objects in the schema and you could encounter object contention issues. Connect as SYS in SQL*Plus and run:

alter session set plsql_optimize_level = 2;
alter session set plsql_code_type = native;
exec dbms_utility.compile_schema('APEX_030200');



That's it! If you execute the query above, you should now see something like:

COUNT(*) OBJECT_TYPE         PLSQL_OPTIMIZE_LEVEL PLSQL_CODE_TYPE
---------- ------------------- -------------------- --------------------
12 FUNCTION 2 NATIVE
370 PACKAGE 2 NATIVE
362 PACKAGE BODY 2 NATIVE
19 PROCEDURE 2 NATIVE
1 TABLE 2 NATIVE
366 TRIGGER 2 NATIVE
4 TYPE 2 NATIVE

7 rows selected.



If you encounter errors and you want to revert back to what you had, run:

alter session set plsql_optimize_level = 2;
alter session set plsql_code_type = interpreted;
exec dbms_utility.compile_schema('APEX_030200');


But I think you'll be pleasantly surprised with the results and have no desire to revert back. In Database 11gR1, this has become a downright trivial exercise. And faster page views means greater throughput which means greater scalability on equivalent hardware. That's both green and economical.

Lastly, you might wonder if the hosted instance of Application Express at http://apex.oracle.com is running with natively compiled PL/SQL. It's not, but after we formally release Application Express 3.2, it will be. There's no reason not to.



Important Update

08-APR-2009: There's nothing like actually using and testing these features on a large-scale system. A few weeks ago, I had natively compiled the APEX engine on apex.oracle.com. But just this past week, we had to switch this back to interpreted. Some unexplained ORA-600 errors were being encountered which is being actively researched by the database development team.

Tuesday, February 17, 2009

Carl Backstrom - Oracle ACE

Thanks to the work of Sharon on our team, she was able fulfill one of the desires Carl Backstrom had expressed a couple times.

The Oracle ACE program was "designed to recognize and reward members of the Oracle Technology and Applications communities for their contributions to those communities. These individuals are technically proficient (when applicable) and willingly share their knowledge and experiences." This really epitomized Carl - he was always ready and willing to share his vast knowledge with any one.

Well, as luck would have it, the folks at the Oracle Technology Network decided that Oracle employees could no longer be awarded the ACE designation. And that bothered Carl a little bit, as he was a very active contributor to the community every day. It just would have been nice to receive that designation.

Thanks to Sharon's suggestion, this has now been achieved: http://forums.oracle.com/forums/profile.jspa?userID=354238

Wednesday, February 11, 2009

apex.oracle.com upgraded to Application Express 3.2

Today (Wednesday, 11-FEB-2009) I upgraded apex.oracle.com to Application Express 3.2.0.00.21. As our long time customers know, this is one of the last milestones in our cycle prior to production release.

You can go here for a brief introduction to the new features in Application Express 3.2. As you'll see, there are two primary themes - Forms Conversion and security. The Application Express 3.2 documentation is not staged yet, but the online help/documentation is current for APEX 3.2.

If you encounter odd behavior or you feel that something was not properly upgraded in your application, please feel free to report it on the APEX OTN discussion forum. We will watch this closely.

Thank you for all of your support.

Friday, November 21, 2008

Change is Coming....

Change is coming...and no, I'm not referring to the forthcoming change in Washington. I'm referring to Oracle Application Express.

Since the first supported release of Application Express (Oracle HTML DB 1.5), Application Express has been delivered as a supported feature of the Oracle Database, supporting database releases 9.2.0.3 and higher. So even though Oracle HTML DB 1.5 was delivered as a feature of the Oracle Database Release 10gR1, a customer could actually download it from the Oracle Technology Network, install it in their Oracle Database 9iR2 9.2.0.3, and be in a supported configuration.

For the forthcoming release of Oracle Application Express 3.2, which introduces Oracle Forms Conversion, the minimum database version will continue to be 9.2.0.3. But for Oracle Application Express 4.0, the minimum database version will be Oracle Database 10gR2 10.2.0.x - possibly even 10.2.0.4.

Thursday, November 13, 2008

What's up, DOAG?

It's pronounced "what's up, dog?"...or if you're a Cleveland Browns fan like I am, it's pronounced "what's up, Dawg?" (my thanks to Sergio for this play on words).

The conference of the German Oracle User's Groups, Deutsche Oracle-Anwendergruppe 2008 Konferenz + Ausstellung (DOAG), is happening Monday 01-DEC-2008 through Wednesday 03-DEC-2008 in Nürnberg, Germany. Here is the conference program in German and English. There are a fair number of presentations about Oracle Application Express, including mine about what's coming new in Oracle Application Express in 2009.

I'm looking forward to the entire conference. Maybe some of the local attendees can take us on a walking tour of the Nürnberger Christkindlesmarkt.

Saturday, November 01, 2008

Carl Backstrom Memorial Announcement

Please join the family in celebrating the life of Carl Backstrom

on Thursday, the sixth of November

two thousand and eight

at one o'clock in the afternoon

Orange Terrace Park

20010 Orange Terrace Park Parkway

Riverside, CA 92508



In lieu of flowers the family has set up a Memorial Fund
in behalf of Carl's daughter, Destany.


Donations to Carl's Memorial Fund can be made several ways:

Domestic wire transfers
Account Number 152460903
Citibank ABA Number 322271724
International wire transfers SWIFT Code: CITI US 33
Checks
Make payable to Susan Bailey (Carl's Mother)
Address: 3395 S. Jones Blvd #403
Las Vegas, NV 89146

“And in the end, it's not the years in your life that count. It's the life in your years.” - Abraham Lincoln





Carl Backstrom Memorial Annoucement
Get your own at Scribd or explore others:

Open Source Web Design

Maybe everyone else on the planet knew about OSWD other than me. Regardless, here goes...

My brother-in-law, Matt Wagner, recently asked me to help him with his Web site. This was an interesting proposition, because I have not invested that much time learning about proper Web design (I never had to - I'm a database guy and we always had Carl and Marc for that kind of stuff). So I took this as an opportunity to actually learn something and I embraced the challenge. My brother-in-law already had his domain name, and he had a rough idea about the layout and the content that he wanted to put on his Web site, but he didn't know the first thing about HTML or how to propagate this information out to GoDaddy.

The last conversation I had with Carl was a week ago and I wanted to get his feedback about what I had done with Matt's Web site. Here is what pointed Carl to. I was so proud of myself, having figured out how to make some practical use of styles and also my over-the-top use of the effects from MooTools. Let me tell you - Carl laughed and laughed. He said the colors were odd, there was no contrast with the font and the background, the effects were funny, and he encouraged me not to use Serif fonts ("just not in style"). He also told me, with a chuckle, that I should start practicing jQuery and forget MooTools.

Carl did point me to the Open Source Web Design site and told me to pick one. For someone like me, who is artistically and graphically challenged, this site is a wealth of excellent templates and ideas. Needless to say, my second attempt at this, which we're continuing to iterate upon, is much, much better.

Thursday, October 30, 2008

From Carl's Mother

Carl's sister Cyndi asked me to share this message from Carl's mother, Susan:


....a very sincere heartfelt thank you everyone for all the caring words coming our way from Carl's internet 'family'.. please know that your words are read and are a comfort to us at this terrible time... his sisters will be writing more later.

Love to all,

Carl's Mom .. Susan

Wednesday, October 29, 2008

Carl Backstrom = WYSIWYG


This posting isn't about Oracle Application Express. It's merely some simple thoughts about our good friend, Carl Backstrom.

I paid attention to the pages of postings on the APEX OTN discussion forum about Carl. Some are from people whom Carl helped once or twice. Others, Carl tirelessly helped many times. Very few of these people actually met Carl, yet they were affected by his death - he touched them in some positive way. I received e-mail from others who only met Carl once or twice, and even they admitted they were affected by this, and couldn't quite pinpoint why. Well...I'll tell you why.

Carl was the definition of WYSIWYG. There was no air about Carl. He was not pretentious in any way. He did not have an agenda. He was not artificial. He was very human and authentic. His omnipresent positive attitude and enthusiasm were sincere and infectious. He was someone you enjoyed being around, someone you wanted to be around. He possessed an intangible, endearing quality.

I enjoyed that Carl was ever so unassuming. If you met Carl for the first time, you might have thought that he's some nice casual fellow who also likes to be a skater in his spare time (turns out, he was a snowboarder). Little would you know that what underlaid his visage was one of the brightest, hardest-working, most creative and visionary minds on the planet when it comes to AJAX, JavaScript, Web 2.0, Web design, RIA - whatever you want to call it. I am not embellishing this fact.

Carl's greatest character flaw, as I see it, was that he could rarely if ever say "no" to someone who was seeking his help. He was always ready to assist someone, no matter who they were, no matter the size of the problem, big or small. What a wonderful "flaw" to have. It is something I can only hope to aspire to.

I shall miss him dearly.

Tuesday, October 28, 2008

Carl Backstrom

As has already been mentioned on the APEX OTN forum and other places on the Internet, our good friend and colleague, Carl Backstrom, passed away on Sunday, 26-OCT-2008.

I spoke with Carl's family last evening. I should have more details later this week, but his family is tentatively planning on a memorial service sometime next week in Riverside, CA. Additionally, his sister said that they're thinking of setting up a trust fund for Carl's daughter, in lieu of flowers or cards. I'll post these details as I get them.

Carl was simply a great guy who touched so many people in such a positive way.

Friday, October 24, 2008

Book for Oracle Application Express and Oracle Forms developers

As most folks already know, the next release of Application Express is 3.2. The primary (and almost sole) new feature in Application Express 3.2 will be Oracle Forms Conversion. This was discussed and demonstrated at Oracle Open World 2008 in San Francisco in September.

When I was at Oracle Open World 2008, I had the good fortune of meeting James Lumsden from Packt Publishing. As it turns out, Packt Publishing is starting a book on Oracle Application Express for Oracle Forms Developers. "It will be a title that shows Forms developers how to ‘get things done’ in Apex, in a practical hands-on way, but with regular cross-reference to their established development techniques, practices and approaches."

Why am I writing about this? Because Packt Publishing is interested in talking to you if you have a desire to contribute to this type of book. If you're interested in further exploring this opportunity, please contact James Lumsden at jamesl@packtpub.com.


* Note: I have no relationship with Packt Publishing. I have contributed to books from Wrox Press and Apress but never Packt, so I cannot give any positive or negative feedback.

Thursday, August 28, 2008

Application Express 3.1.2 Released

This afternoon we released Application Express 3.1.2. As for every patch set for Application Express, we released this in the form of a patch set on MetaLink (Patch Number 7313609) as well as a full release which can be downloaded from OTN. Thus:

  1. If you have Application Express 3.1 or 3.1.1 installed, you'll want to download the APEX 3.1.2 patch set and apply it.
  2. If you have Application Express 3.0 or earlier installed (all the way back to HTML DB 1.5), you'll want to download and install the entire APEX 3.1.2 release from OTN.
  3. If you don't have Application Express installed, you'll want to download and install the entire APEX 3.1.2 release.
Application Express 3.1.2 is inclusive of the modifications made for Application Express 3.1.1 as well as some new bug fixes. It also includes corrections for a couple of regressions (unfortunately) introduced in the APEX 3.1.1 patch set as well as the issues introduced in APEX 3.1.1 with the labels and 2D Flash charts. Lastly, we took Billy V's comments to heart and revised the patch set installation instructions (although I'm sure we'll get further opinions).

The Application Express 3.1.2 patch set was applied to http://apex.oracle.com on Wednesday, 27-AUG-2008.

Friday, August 08, 2008

Oracle Application Express and Oracle MetaLink

When customers have questions about the scalability of Oracle Application Express or Oracle’s commitment to Application Express, the use of Application Express in Oracle MetaLink is often cited by other customers.

Recently, an e-mail from the Oracle MetaLink team went out to MetaLink users, inviting them to try out the new Oracle MetaLink and get their feedback. The new MetaLink is not written with Oracle Application Express, prompting some customers to write an e-mail to me and ask me what’s going on. There was also a recent discussion on one of the ODTUG mailing lists about this very topic. Here are some statements which will undoubtedly be inferred from this change:

  1. Oracle is no longer committed to Oracle Application Express
  2. Oracle Application Express couldn’t handled the scalability needs of Oracle MetaLink

Let me say that both of these statements are false.

Oracle acquired many companies and products over the past few years. Included in these acquisitions was software to help manage the customer relationship. This really became a business decision of either continuing to maintain and extend custom-written software in Oracle Application Express and PL/SQL, or use the off-the-shelf software that Oracle sells. As Tom Kyte often references the “Buy versus Build” decision, this one was even simpler – “Buy versus Own”.

That’s the decision in a nutshell. Anything else inferred from this change would be factually incorrect.

Tuesday, July 29, 2008

Using Oracle Application Express and the Oracle eBusiness Suite?

Are you using Oracle Application Express in conjunction with the Oracle eBusiness Suite? If so, then we'd like to hear from you!

David Peake recently blogged about this, and is collecting information from the Oracle Application Express community. The purpose of this is to gather evidence with the eventual goal of formally legitimizing the use of Oracle Application Express with the Oracle eBusiness Suite.

If you are currently using Oracle Application Express with the Oracle eBusiness Suite (or other Oracle Applications, for that matter), I encourage you to read his blog and take his one page survey. You can provide as much or as little information as you wish, and you have my personal assurances - no sales or marketing representative will call.

Thursday, July 17, 2008

Export data from Oracle Application Express and import via Oracle SQL*Loader

The other day, Josie from Oracle asked me:

"When I export the data, both as csv and xml the date is exported like this: 2005-08-29T00:00:00. sqlldr has a fit about that!"

What she was saying, in rather abbreviated form, was that she was having difficulty using the Oracle utility SQL*Loader to import a data file which was exported from Application Express -> Utilities -> Data Load/Unload. In particular, Josie was having difficulty loading the data of datatype DATE.

If you Unload to Text the EMP table, you'll get something that looks like:

"7839","KING","PRESIDENT","","1981-11-17T00:00:00","5000","","10"
"7698","BLAKE","MANAGER","7839","1981-05-01T00:00:00","2850","","30"
"7782","CLARK","MANAGER","7839","1981-06-09T00:00:00","2450","","10"
"7566","JONES","MANAGER","7839","1981-04-02T00:00:00","2975","","20"
"7788","SCOTT","ANALYST","7566","1982-12-09T00:00:00","3000","","20"
"7902","FORD","ANALYST","7566","1981-12-03T00:00:00","3000","","20"
"7369","SMITH","CLERK","7902","1980-12-17T00:00:00","800","","20"
"7499","ALLEN","SALESMAN","7698","1981-02-20T00:00:00","1600","300","30"
"7521","WARD","SALESMAN","7698","1981-02-22T00:00:00","1250","500","30"
"7654","MARTIN","SALESMAN","7698","1981-09-28T00:00:00","1250","1400","30"
"7844","TURNER","SALESMAN","7698","1981-09-08T00:00:00","1500","0","30"
"7876","ADAMS","CLERK","7788","1983-01-12T00:00:00","1100","","20"
"7900","JAMES","CLERK","7698","1981-12-03T00:00:00","950","","30"
"7934","MILLER","CLERK","7782","1982-01-23T00:00:00","1300","","10"



What should stand out to you is the value for the EMP.HIREDATE column. Why is it formatted this way?

To explain it simply, users of Application Express span all possible countries, territories and languages. A date format that works in one language may not work in another. A good example is a date value that contains an actual month name or an abbreviation of a month name. Today's date in English in Oracle date format DD-FMMonth-RRRR would be 17-July-2008. But change your language to German and you'll get 17-Juli-2008. If your data contains '17-July-2008' and you try to import it into a system with German language settings, it will fail - 'July' is not a valid month name in German.

For the export of DATE type data from Application Express, we needed to use something that works across all languages. We could have devised our own canonical date format. But instead, we decided to employ the international representation of date and time, namely, ISO 8601. So for those who scratch their head and wonder where that odd "T" comes from in the date value, here is your answer.

With this understanding in place of why this value is in this odd-looking format, let's get back to Josie's original question - how do I import this using SQL*Loader? Using a SQL *Loader SQL Operators and escape characters, it's quite easy. Here is a SQL*Loader control file which can be used to load the EMP data from above:

load data
infile "/tmp/emp.txt"
append into table emp
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(EMPNO, ENAME, JOB, MGR, HIREDATE "to_date(:HIREDATE,'rrrr-MM-dd\"T\"HH24:mi:ss')", SAL, COMM, DEPTNO)



The critical element in the field list, of course, is:

HIREDATE "to_date(:HIREDATE,'rrrr-MM-dd\"T\"HH24:mi:ss')"

which is simply applying a TO_DATE SQL operator to the HIREDATE field of the data file. Additionally, the data value will be represented as a string in a specific format. The double-quotes before and after the 'T' must be escaped, so SQL*Loader doesn't try to interpret that as the end of the expression.


Happy loading.

Monday, July 14, 2008

Oracle eBusiness Suite and mod_plsql

There have been a fair number of questions and concerns about the use of mod_plsql and the Oracle eBusiness Suite. And unfortunately, this has created some confusion about what is and is not supported by Oracle. I know a fair number of customers, both large and small, who are successfully using Oracle Application Express and the Oracle eBusiness Suite just fine.

Steven Chan, who is a Senior Director in the Oracle Applications group, has recently blogged about the availability of a new whitepaper on MetaLink. The whitepaper entitled mod_plsql and Oracle E-Business Suite Release 12 (MetaLink Note 726711.1) is intended to discuss many of the issues around mod_plsql and the Oracle eBusiness Suite.

Thursday, May 22, 2008

Application Express 3.1.1 released

Today (22-MAY-2008), the Oracle Application Express 3.1.1 patch set was released. This patch set can be applied to an instance running Oracle Application Express 3.1.0.00.32.

Soon (hopefully later today), the full distribution of Application Express 3.1.1 will be available for download on OTN. This distribution will not enable you to patch an existing Application Express 3.1 instance to Application Express 3.1.1. You will need the patch set from Oracle MetaLink for this.

This patch set does not introduce any new features. This patch set fixes a collection of software defects (i.e., bugs) found internally as well as issues reported on the active Application Express OTN discussion forum. All resolved issues are documented in the README.html file contained with the Application Express 3.1.1 patch set.

To find this on MetaLink:

  1. Login to MetaLink
  2. Click the "Patches and Updates" tab
  3. Click "Simple Search"
  4. For Patch Number/Name, enter: 7032837
  5. Click Go

Friday, May 16, 2008

The Oracle APEX Award

Just announced today is a competition in Germany called The Oracle APEX Award, with a grand prize of € 5,000 (approximately $7700 USD). Now it can't be just any application - it should be business related, based on APEX 3.0 or later, delivered with supporting objects and an installation script (so it is a single file deliverable, just like the Packaged Applications), and run on Oracle Database 10g or Oracle Database 11g.

Beyond the money, though, all Oracle Application Express solutions from the competition will be promoted by Heise, Mittelstandswiki and on the German Oracle General Business Sites.

In case you were worried that this competition would be won by Patrick Wolf, he can't participate, as he is one of the judges.

Why APEX?

Why use Application Express? What is it good for? Good questions.

Today I stumbled upon a 3 minute viewlet about Oracle Application Express. And I honestly couldn't tell you who did this, although I do remember David Peake (the Application Express Product Manager) making mention of this a month or two ago.

If you're curious about Oracle Application Express, this is worth 3 minutes of your life.

Wednesday, April 16, 2008

Zip it!

For those of you thinking this is a posting about Dr. Evil from the Austin Powers movie, you'll be disappointed. However, if you have ever wanted a way to create a zip file in PL/SQL in an Oracle database, then this one is for you.

This question has come up many times over the years. There are many ways to export files from Oracle Application Express (applications, images, data in XML, etc.), but wouldn't it be great if this could be downloaded as a single file, or at a minimum, as a zip archive of these files? Of course - but I was never aware of a simple way to pull this off.

Then along comes the Oracle Multimedia team (a supremely competent and professional team - led by Sue Mavris) . At Oracle OpenWorld last year, the Oracle Multimedia team demonstrated DICOM support in the 11gR1 database. They created a couple applications in Application Express for this demonstration. I was recently reviewing these applications and I came across an interesting piece of code which does the creation of a zip archive for any number of BLOBs. All credit for this code must be given to Fengting Chen from the Oracle Multimedia team - I just modified it slightly for this posting.

This solution requires the Java VM in the Oracle database. I tried this out on an 11gR1 11.1.0.6 database, but I imagine this may work for earlier database versions as well. It's nothing more than a Java class that is compiled into the database and then a call specification which is used to publish the Java method to SQL and PL/SQL. It's unbelievably elegant.

Using either SQL*Plus or SQL Commands in SQL Workshop, run the following script:

create or replace java source named ZipLobs as

//---------------------------------------------------------------------------
// File name: ZipLobs_java.sql
// Description: Java Stored Procedure that zips the data of BLOBS returned
// by the query and writes into a destintation BLOB.
//---------------------------------------------------------------------------


import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import oracle.jdbc.OracleDriver;

public class ZipLobs {
public static int writeZip(
String query,
Blob[] outLob) {
try{
//ceate the zipoutputstream from the end of the outLob
Blob zipLob = outLob[0];
OutputStream os = zipLob.setBinaryStream(1);
ZipOutputStream zos = new ZipOutputStream(os);

//execute the query.
int chunksize = 32768;
Connection conn = new OracleDriver().defaultConnection();
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
while (rset.next()) {
// get the id and the data columns
String filename = rset.getString( 1 );
Blob src = rset.getBlob( 2);


//add one zip entry
ZipEntry entry = new ZipEntry(filename);
zos.putNextEntry(entry);

//write data to the zip lob
long len = src.length();
long offset = 1;
byte[] buffer;
while (offset < len) {
buffer = src.getBytes(offset, chunksize);
if (buffer == null)
break;

zos.write(buffer, 0, buffer.length);
offset += buffer.length;
}
zos.closeEntry();
}
zos.close();

outLob[0] = zipLob;

}catch (Exception e) {
e.printStackTrace(System.out);
return 1;
}
return 0;
}
}
/


After this is compiled, it will create an object of type JAVA SOURCE as well as another object of type JAVA CLASS, both of which may initially be invalid. To correct this, issue the statement:


alter java source ziplobs compile;


Lastly, create the call specification to make this class visible from PL/SQL:


--
-- The zip utility that zips data in multiple BLOBs and returns
-- into a single BLOB
--
-- Parameters:
-- p_query: The SQL query which must select the filename as the first
-- column and the BLOB data to be zipped as the second column
--
-- p_zip: BLOB variable which will contain the contents of the zipped BLOBS
--
-- Return 0: Success
-- 1: Error occured
--
-- Example:
--
-- ziplobs('select fname, resume from docs where id < 10', l_zip );
--
create or replace function ziplobs(
p_query in varchar2,
p_zip in out nocopy blob )
return number
as language java
name 'ZipLobs.writeZip(
java.lang.String,
java.sql.Blob[]) return int';
/


That's all there is to it! Now you have a procedure which you can use to zip all sorts of things. You could use this to zip up a collection of PDF's and present it as a single file download to the end user. You could author a database job which uses DBMS_XMLGEN to generate XML files for the data in your tables, zip all of them up, and store it directly in the database. You could write a procedure which takes a number of files, zips them up, and e-mails them.

Using the PL/SQL package APEX_MAIL which supports e-mail attachments (as of Application Express 3.1), here's a practical example:


declare
l_id number;
l_blob blob;
l_dummy integer;
begin
l_id := apex_mail.send( p_to => 'fred.flintstone@bedrock.com',
p_from => 'barney.rubble@bedrock.com',
p_subj => 'Images',
p_body => 'Here are the images I promised -- Barney' );
dbms_lob.createtemporary( l_blob, TRUE );
l_dummy := ziplobs( 'select filename, blob_content from apex_application_files ' ||
'where mime_type like ''%gif%'' and rownum < 5',
l_blob );
apex_mail.add_attachment( l_id, l_blob, 'ImagesForFred.zip', 'application/zip');
commit;
end;
/


While I would like to think that this would eventually make it into a distribution of Application Express, the biggest impediment is the dependency upon Java in the database. We removed this dependency beginning with Application Express 2.2, at the request of a number of customers. But with that said, I'm sure this will make its way into a number of packaged applications and other utilities provided by our team.

Wednesday, March 19, 2008

Preserving checked checkboxes in a report

Paul from Oracle recently sent me an e-mail with the following request:

"I am using the report template to display the database table contents. Before each report data in the display I added a checkbox to allow user to select the data. I can get the checked data id from global package array apex_application.G_F01 when user submits the page. However, this array is cleared whenever the user browses the report to the next page using the ApEx navigation. How could I save the checked checkbox when user is browsing the report using "next" or "previous" links? This issue also appears if you change the number of rows displayed. I looked on the APEX forum on OTN and could not find a solution. Any help you can give is greatly appreciated."

I understood the problem exactly. Paul has a report on a page with a checkbox column (presumably using APEX_ITEM.CHECKBOX). A user will check a few boxes and then click the Next link to display the next set of rows in the report. But now when the user goes back to the first page, the original checked checkboxes are no longer checked. This is because the checked checkboxes are not preserved in session state.

I poked around the OTN forum myself and could not find this addressed. I even browsed Carl's and Denes' demonstration applications, and even though there are all kinds of exotic examples, this simple (and seemingly common problem) didn't seem to be addressed - at least not for the common man.

Using Application Express collections and a little AJAX, we should be able to solve this rather elegantly.

In my workspace on apex.oracle.com, I:

  1. Started the creation of a new application
  2. Added a report, Page Source = Table, Table Name = EMP, Implementation = Classic
  3. Clicked the Create Button

When running this application, you should get something that looks like:




Standard stuff, right?

Now, to add the checkbox using the APEX_ITEM.CHECKBOX API, I changed the SQL query and added one line:

select
apex_item.checkbox(1, empno) cbox,
"EMPNO",
"ENAME",
"JOB",
"MGR",
"HIREDATE",
"SAL",
"COMM",
"DEPTNO"
from "EMP"
where
(
instr(upper("ENAME"),upper(nvl(:P1_REPORT_SEARCH,"ENAME"))) > 0 or
instr(upper("JOB"),upper(nvl(:P1_REPORT_SEARCH,"JOB"))) > 0
)


Now, after shuffling the cbox column up in the report display order and clearing out the column header, it should now look like:


Now here's where the fun starts. You can liken Application Express collections to temporary tables - they're an amorphous bit bucket to store vectors of information, in contrast to the scalar declarative item types. The nice thing about collections is that they are tied completely to an Application Express session. As those get cleaned up automatically, so does the data in collections. So we will use an Application Express collection to maintain a list of the EMPNO values of the checked rows.

First, I created an unconditional On Demand application-level process named "UpdateCheckboxValue" using the following code:

declare
l_value varchar2(4000);
l_seq_id number := 0;
l_collection_name constant varchar2(30) := 'EMP_COLLECTION';
begin
--
-- Get the value of the global which will be set in JavaScript
--
l_value := wwv_flow.g_x01;

--
-- If our collection named EMP_COLLECTION doesn't exist yet, create it
--
if apex_collection.collection_exists( l_collection_name ) = FALSE then
apex_collection.create_collection( p_collection_name => l_collection_name );
end if;

--
-- See if the specified value is already present in the collection
--
for c1 in (select seq_id
from apex_collections
where collection_name = l_collection_name
and c001 = l_value) loop
l_seq_id := c1.seq_id;
exit;
end loop;

--
-- If the current value was not found in the colleciton, add it. Otherwise, delete it from the collection.
--
if l_seq_id = 0 then
apex_collection.add_member(
p_collection_name => l_collection_name,
p_c001 => l_value );
else
apex_collection.delete_member(
p_collection_name => l_collection_name,
p_seq => l_seq_id );
end if;
commit;
end;


So this elegant piece of code will take care of creating a collection named EMP_COLLECTION, and then determine if we should add or remove the value from the collection. The name of the process, "UpdateCheckboxValue", is relevant, as we'll use it next.

Next, after glancing at Carl's simple AJAX and On Demand example, I figured out the JavaScript I needed. So I edited the page attributes of page 1 and added the following to the HTML Header section:

<script type="text/javascript">
<!--

function f_UpdateCollection( cb ){
var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=UpdateCheckboxValue',0);
get.addParam('x01',cb.value);
gReturn = get.get();
get = null;
}
//-->
</script>



Now, I have a JavaScript function on my page which will invoke the On Demand application-level process I defined above. All I need to do is hook it up. To do that, I can now modify the call to APEX_ITEM.CHECKBOX to invoke this function in an 'onchange' event:

select
apex_item.checkbox(1, empno, 'onclick="f_UpdateCollection(this)"') cbox,
"EMPNO",
"ENAME",
"JOB",
"MGR",
"HIREDATE",
"SAL",
"COMM",
"DEPTNO"
from "EMP"
where
(
instr(upper("ENAME"),upper(nvl(:P1_REPORT_SEARCH,"ENAME"))) > 0 or
instr(upper("JOB"),upper(nvl(:P1_REPORT_SEARCH,"JOB"))) > 0
)


If you now run the application and click the checkboxes, you may notice a slight lag. That's because, behind the scenes, a request is being made from your browser to the Application Express engine, which is calling the On Demand application-level process and modify data in the collection for your session.

But we're not quite done. We need to somehow "merge" what we have stored in the collection with the query for our report. This can be achieved by modifying the call to APEX_ITEM.CHECKBOX to add the fourth argument which indicates if a value should be checked or not, and also modifying the query itself to perform an outer join against APEX_COLLECTIONS.

select
apex_item.checkbox(1, empno, 'onclick="f_UpdateCollection(this)"',a.c001) cbox,
"EMPNO",
"ENAME",
"JOB",
"MGR",
"HIREDATE",
"SAL",
"COMM",
"DEPTNO"
from "EMP", apex_collections a
where
(
instr(upper("ENAME"),upper(nvl(:P1_REPORT_SEARCH,"ENAME"))) > 0 or
instr(upper("JOB"),upper(nvl(:P1_REPORT_SEARCH,"JOB"))) > 0
)
and a.c001 (+)= empno
and a.collection_name (+)= 'EMP_COLLECTION'



This query will still report on every row in the EMP table, and optionally on the EMP_COLLECTION where the join condition is met. In the reference to a.c001 in the call to APEX_ITEM.CHECKBOX, for those rows in EMP for which there is no match, the resultant value will be NULL. For those rows which do match (a.c001 = EMPNO), then the value of
a.c001 should be the corresponding EMPNO value, and this will result in the checkbox being checked.

There certainly will be a need to clear the collection, so I added a PL/SQL process on the page which will execute on Submit and when the Reset button pressed of:


apex_collection.create_or_truncate_collection(
p_collection_name => 'EMP_COLLECTION' );
commit;


This will clear the collection if it exists, and create it if it doesn't exist. I easily could have used apex_collection.truncate_collection, but I'd have to account for the case where the collection is not already created.

The complete application is here: http://apex.oracle.com/pls/otn/f?p=blog_20080319:1:0

I completely realize some "expert" is going to flame me, telling me this was solved in 2004 and here's the proof. But I was astonished that I couldn't find an article discussing this type of problem and solution.

Caution: The implementation above can be quite "chatty". Every time someone clicks a checkbox, they will make a request to the Web server and the database. There are other ways to implement this solution, but this will work for reports with and without PPR.

Web browser "compatibility"

Is this an article dealing with Oracle Application Express? Barely.

I recently read the latest treatise from Joel Spolsky of "Joel on Software" fame. Joel does an excellent job of explaining the history of the Web "standards" which have gotten everyone into a little bit of a mess. And even though standards have been developed for HTML and Web browsers, it's always a challenge to maintain backward compatibility.

http://www.joelonsoftware.com/items/2008/03/17.html

When I read this, I couldn't help but think of poor Carl on our team who wrestles with these same challenges for every release of Oracle Application Express. It's hard enough to produce a Web application development environment which enables you to build applications to work elegantly with Firefox and Internet Explorer. This is why you don't see certification for Opera, Netscape Navigator, Safari and the like. They're all a little bit different.

I'm still waiting for the Oracle Application Express theme which supports Lynx.

Tuesday, March 18, 2008

Oracle Application Express and NTLM authentication over HTTP

Jason Straub, my friend, work colleague and fellow member of the APEX Columbus Development Organization, has decided to join the Oracle Application Express blogging world. Jason's first posting is about NTLM authentication with Oracle Application Express and how this can be achieved without the use of mod_ntlm.

http://jastraub.blogspot.com/2008/03/ntlm-http-authentication-and.html

Wednesday, March 12, 2008

And the winners are.....

In mid-February, I solicited the feedback from the APEX community about Application Express and which languages we should consider translating to. In later February, Sharon also posted an announcement on the Application Express discussion forum on OTN.

With the crush of the APEX 3.1 release behind us, I decided to review the results. And they were surprising. Out of a total of 149 legitimate responses, the top 5 were:

  1. Hungarian
  2. Russian
  3. Arabic
  4. Dutch
  5. Polish



Granted, I can't claim that this was a scientific survey. It only reached the folks who decided to read my blog posting (unlikely) or follow the link from the announcement on the OTN discussion forum. Or maybe the folks in Hungary started an e-mail campaign and decided to stack the deck. Regardless, this gives me enough information now to approach the managers in these respective regions to assess market opportunity.

Thank you to everyone who provided your invaluable feedback. The full results can be viewed here:

http://apex.oracle.com/pls/otn/f?p=apex_lang_survey:survey_results:0

Oracle Application Express Technology Briefing

On Thursday, March 27, 2008, Oracle and Progressive Skill will present a technology briefing on Oracle Application Express. The event location is Smith & Wollensky Restaurant. Discussions will include:
  • Reasons for failed/delayed custom software projects
  • Advantages of Rapid Application Development
  • How Oracle Application Express facilitates Rapid Development better than any development tool on the market
  • Successful software applications built using Oracle Application Express
  • Real world examples of custom built Oracle Application Express Applications

For more information and to register, you can go here.

Friday, February 29, 2008

Application Express 3.1 released on OTN

Today, February 29, 2008, Application Express 3.1 was released for download on the Oracle Technology Network. Start at http://apex.oracle.com, follow the link to Download Application Express, and away you go.

Sharon posted an announcement here.

Thursday, February 28, 2008

apex.oracle.com upgraded to Application Express 3.1

Yesterday, February 27, the hosted demonstration instance of Oracle Application Express at http://apex.oracle.com was upgraded to Application Express 3.1. This is one of the last milestones in the release criteria for Application Express. If we can successfully upgrade an instance with over 11,000 workspaces and over 30,000 applications, this usually bodes well for the product release.

It's an incredibly valuable learning experience running and managing apex.oracle.com. There's nothing like using your own software.

There were over 1,100 participants in the hosted Early Adopter's release of Application Express 3.1. The feedback was invaluable, from comments to suggestions to bug reports. The Application Express community has my gratitude.

Joel

Saturday, February 16, 2008

Should Oracle Application Express be translated into other languages?

Today, Oracle Application Express is delivered in a total of 10 languages:

  • de - German
  • es - Spanish
  • fr - French
  • it - Italian
  • ja - Japanese
  • ko - Korean
  • pt-br - Brazilian Portuguese
  • en-us - English United States
  • zh-cn - Simplified Chinese
  • zh-tw - Traditional Chinese

As you may already know, a developer-created Application Express application can be translated into any language. But for the development environment of Application Express (Application Builder, SQL Workshop, Access Migration, Utilities, Internal Administration), should this be translated into additional languages?

I am specifically interested in the market opportunity for Application Express, and not necessarily your personal preference.

If you wish to let your voice be heard, please feel free to take this one-question survey at:

http://apex.oracle.com/pls/otn/f?p=apex_lang_survey:1:0

Tuesday, February 12, 2008

Who uses apex.oracle.com?

For those who don't know, Oracle hosts a demonstration version of Oracle Application Express at http://apex.oracle.com. Anyone on the planet can sign up for a workspace, and as long as you don't run a production or commercial Web site, don't do anything illegal and also understand that there is no Service Level Agreement, it's all yours to try out Oracle Application Express. The ultimate goal, though, is for anyone to try Application Express with without having to download, install, or configure anything. All you need is a modern Web browser. And trust me - no one from sales or marketing will call.

In late 2007, I became inspired and installed some Google Analytics JavaScript code in the Login Message and System Message areas of the Application Express instance (you access this from internal administration, Manage Service -> Messages). This tracks access to the Login page and almost all of the pages in Application Builder, SQL Workshop and Utilities. It does not track any information for user-created applications - only the development environment and the general APEX login page. And it's only used for general information and also to satisfy my curiosity.

If you've ever used Google Analytics before, you're already aware of the wealth of information that is recorded. So who uses apex.oracle.com? Looking at the number of visits broken down by country from December 1, 2007 through February 12, 2008:
  • United States - 30%
  • United Kingdom - 10.5%
  • India - 10%
  • Germany - 6%
  • Netherlands - 3%
What I did find most surprising was that Japan was listed as #12, even though I know there has been reasonably good interest in Application Express in Japan, China and Korea since the days of HTML DB 1.5.

The top 25 are here:



I also found interesting the keywords people used on Google to navigate to apex.oracle.com. Four of the top ten are related to Denes Kubicek. Congratulations, Denis!



Please don't confuse these statistics with overall scalability of this instance or Application Express. I'm only presenting the Google Analytics visits. For the past week, on apex.oracle.com, there were:
  • 1,637,781 page views
  • 2,093 distinct applications used in the past week
  • 2,947 distinct users authenticated in the past week
  • 224 new workspaces approved
  • 13,745 total workspaces
It's running on a Dell PowerEdge 1950 with 2 Dual Core Xeon processors. Average load on the database server hovers around 16%.



Update: In response to Denes' request for the top used applications, I've found the following in descending order of activity in the past week:


PROMED: ProMED-mail Public Site
WORK: OTN EXAMPLES
DKUBICEK: My Demo Application
RTI: OCU_BCK
ASKSTEVEN: AskSteven
EBA: Checklist Manager 1.0
EBA: Online Store 1.0
DBTOOLS: SQL Developer Exchange
OSC: OnScreen
HENRY: Avance Issue Tracker 1.0
ACES: Oracle ACEs
MIKA: MyFirehouse
PALGW: Applicant Tracking System
EBA: Asset Manager 1.0
EMAIL_HELPDESK: Email Helpdesk
JOEL2: Workspace Purge



Granted, I did have to filter some stuff out, because Application Builder and SQL Workshop are always in the top 10. Also, there are some applications for SQL Developer and JDeveloper check-for-updates which are not really relevant to Denes' question.

I think Denes is really trying to rub it in. Note how the Workspace Purge application has generated much activity as people scramble to preserve their seldom-used workspaces.

Oracle Unbreakable Linux and Oracle VM Server Virtualization - Briefing in Columbus, Ohio

For those who care (and are in Central Ohio), next week Wednesday, February 20, 2008, my good friend Sergio Leunissen will be in town presenting Oracle Unbreakable Linux and Oracle VM Server Virtualization. All of the details are here:

http://www.oracle.com/dm/08q3field/12389_ev_ent_arc_brie_feb20.html