tag:blogger.com,1999:blog-61392503712779789642024-03-12T23:20:15.049-04:00Application Express Nuggets(The views expressed here are my own and do not necessarily reflect the views of Oracle.)Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-6139250371277978964.post-58671446185416985152019-10-29T10:32:00.002-04:002019-10-29T10:32:29.684-04:00How to Script Workspace Provisioning on Oracle Autonomous DatabaseI have moved my blogging over to blogs.oracle.com/apex. See my latest post <a href="https://blogs.oracle.com/apex/how-to-script-workspace-provisioning-on-oracle-autonomous-database">here</a>.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-82906607446316741812018-11-13T13:13:00.003-05:002024-03-08T14:24:36.250-05:00Multitenant ORDS with Local APEX in PDBsOracle REST Data Services (ORDS) has a great feature that allows you to <a href="https://docs.oracle.com/en/database/oracle/oracle-rest-data-services/18.3/aelig/configuring-REST-data-services.html#GUID-694B2F89-CE4F-4AB0-88E2-EB35D03DEC3C" target="_blank">address PDBs</a> that have APEX in them, just by using the name of the PDB in the URL, right after the ORDS context root. So if I have two PDBs, named apex181 and apex182, I can address them with URLs similar to the following:<br />
<br />
http://localhost:8080/ords/apex181/<br />
<br />
and...<br />
<br />
http://localhost:8080/ords/apex182/<br />
<br />
The names of my PDBs imply that I have two different versions of APEX installed in the CDB. This is only possible if APEX is installed locally in each PDB and not in CDB$ROOT. To allow for ORDS to be multitenant while APEX is local to the PDBs, you must pre-create APEX_PUBLIC_USER, APEX_LISTENER, and APEX_REST_PUBLIC_USER database users as common users in the CDB. You can do this easily with the <a href="https://docs.oracle.com/en/database/oracle/oracle-database/18/multi/administering-a-cdb-with-sql-plus.html#GUID-E307DC5F-52A9-4B1B-8999-3E60867009D4" target="_blank">$ORACLE_HOME/rdbms/admin/catcon.pl</a> perl utility script for running Oracle supplied scripts.<br />
<br />
<h3>
Create APEX Users Common</h3><span style="font-family: courier;">
$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -b create_apex_pub -- --x'grant create session to apex_public_user identified by oracle'</span><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -b create_apex_list -- --x'grant create session to apex_listener identified by oracle'</span></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -b create_apex_rest_pub -- --x'grant create session to apex_rest_public_user identified by oracle'
</span><div>
<br /></div>
<div>
Obviously you will want to come up with a better password than the ones in the example above. Also note that I am using a funny syntax to create the users, using the grant statement. This allows me to create the user and do the grant in one statement.</div>
<div>
<br /></div>
<h3>
Install ORDS Multitenant</h3>
<div>
Follow the <a href="https://docs.oracle.com/en/database/oracle/oracle-rest-data-services/18.3/aelig/installing-REST-data-services.html#GUID-6F7B4E61-B730-4E73-80B8-F53299123730" target="_blank">advanced installation instructions</a> for installing ORDS, making sure you specify the service name of the CDB.</div>
<div>
<br /></div>
<pre class="sql" name="code">java -jar ords.war install advanced</pre>
<div>
<br /></div>
<h3>
Make All PDBs Addressable </h3>
<div>
To make all PDBs, including newly created PDBs addressable through a URL, you add a parameter to the defaults.xml file which can be found in the ords directory in the location you specified during installation. The value of the parameter should match the database parameter DB_DOMAIN.</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">SQL> show parameter DB_DOMAIN</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">NAME<span style="white-space: pre;"> </span> TYPE<span style="white-space: pre;"> </span> VALUE</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">------------------------------------ ----------- ------------------------------</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">db_domain<span style="white-space: pre;"> </span> string</span></div>
</div>
<div>
<br /></div>
<div>
In my case, there is no DB_DOMAIN value, so in defaults.xml, I made the following entry:</div>
<div>
<br /></div>
<pre class="sql" name="code"><entry key="db.serviceNameSuffix"></entry>
</pre>
<div>
<br /></div>
<div>
Otherwise, enter the value you see for parameter DB_DOMAIN and make sure you precede it with a dot, or period (.). </div>
<div>
<br /></div>
<h3>
Install APEX Locally in each PDB</h3>
<div>
The last step is to install APEX locally in the PDB. After you install APEX, you can access it through ORDS, by appending the name of the PDB name, after the ords context root in the URL.</div>
</div>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-28878460673963076272018-07-19T13:15:00.000-04:002018-07-19T13:15:47.893-04:00Removing Prior Versions of APEX in a PDB<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://twitter.com/dgielis" target="_blank">Dimitri Gielis</a> discovered a possible gap in our Application Express Installation Guide about removing prior versions of APEX, when APEX is installed locally in a PDB. If you follow our recommendation to remove the prior version of APEX after a successful upgrade to APEX 18.1, you might run into something similar to the following:</span><br />
<br />
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">SQL> alter session set container=APEX18;</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"><br class="" /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">Session altered.</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"><br class="" /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">SQL> SELECT username</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"> FROM dba_users </span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"> WHERE ( username LIKE 'FLOWS\_______' ESCAPE '\'</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"> OR username LIKE 'APEX\_______' ESCAPE '\' )</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"> AND username NOT IN ( SELECT schema</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"> FROM dba_registry</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"> WHERE comp_id = 'APEX' ); 2 3 4 5 6 7 </span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"><br class="" /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">USERNAME</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">--------------------------------------------------------------------------------------------------------------------------------</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">APEX_050100</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"><br class="" /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">SQL> DROP USER APEX_050100 CASCADE;</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">DROP USER APEX_050100 CASCADE</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">*</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">ERROR at line 1:</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";">ORA-28014: cannot drop administrative users</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; text-size-adjust: auto;">
<span class="" style="font-family: "courier new";"><br /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); text-size-adjust: auto;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">You would encounter this error if you followed section "<a href="https://docs.oracle.com/database/apex-18.1/HTMIG/performing-post-installation-tasks-for-upgrade-installations.htm#HTMIG-GUID-873974DC-E199-4FE0-BBBE-7FD5A6B75465" target="_blank">4.14.3 Removing Schemas from Prior Installations</a>" in the Installation Guide. The section you actually need to follow is "<a href="https://docs.oracle.com/database/apex-18.1/HTMIG/performing-post-installation-tasks-for-upgrade-installations.htm#HTMIG-GUID-873974DC-E199-4FE0-BBBE-7FD5A6B75465" target="_blank">4.14.4 Removing Schemas from Prior Installations in a CDB</a>." Now, you may argue that since APEX is installed locally, you are not installed in a CDB. But you actually are. You just don't have APEX installed in CDB$ROOT, but your database architecture is still a CDB. You need to use catcon.pl to drop the Oracle Maintained APEX_050100 schema like the following example:</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); text-size-adjust: auto;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); text-size-adjust: auto;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<div class="" style="text-size-adjust: auto;">
<span style="font-family: "courier new" , "courier" , monospace;">$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -b drop_apex050100 -- --x'drop user APEX_050100 cascade'</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">
</span>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">
</span></div>
<div class="" style="caret-color: rgb(0, 0, 0); text-size-adjust: auto;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="" style="caret-color: rgb(0, 0, 0); text-size-adjust: auto;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The command above though will run in every container, or PDB, in the CDB. In some containers, APEX_050100 will not exist, and you will see an error in the catcon logs. Also, you may only want to drop the APEX_050100 schema from a particular PDB. There is the gap in the documentation, and what we need to add to the next version. In my case, my PDB was called APEX18, so to drop APEX_050100 only in the APEX18 PDB, the command would be:
</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -b drop_apex050100 -c 'APEX18' -- --x'drop user APEX_050100 cascade'
</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">We will add this example as well as try and make the section title and lead in more clear in the next version of the Installation Guide.</span></div>
Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-47339759947029715152018-03-16T16:31:00.000-04:002018-03-16T16:31:42.146-04:00APEX 18.1 New Feature: Logging Web Service RequestsAPEX has turned 18 (ish) and <a href="https://apexea.oracle.com/" target="_blank">EA-2 is now available</a>. In this post, I will introduce a brand new (very small) feature of APEX 18.1.<br />
<br />
APEX has had some support for consuming web services even before it was a shipped product (even before it was called HTMLDB). With this release of APEX, Carsten Czarski has made consuming RESTful style web services and the new ORDS REST Enabled SQL feature a breeze. You can read all about this new support in a series of excellent blog posts by Carsten <a href="https://blogs.oracle.com/apex/" target="_blank">here</a>.<br />
<br />
Also introduced in this release is a log of all web service requests made through APEX. Whether they are made through the greatly improved RESTful Web Sources and <a href="https://docs.oracle.com/database/apex-18.1/HTMDB/accessing-data-remotely-using-rest-enabled-sql.htm#HTMDB-GUID-94515117-40F3-42FC-BBB2-EE77315DF434" target="_blank">Remote SQL</a>, the legacy web service REST and SOAP web references, or either the <a href="https://docs.oracle.com/database/apex-18.1/AEAPI/APEX_WEB_SERVICE.htm#AEAPI537" target="_blank">APEX_WEB_SERVICE</a> or <a href="https://docs.oracle.com/database/apex-18.1/AEAPI/APEX_EXEC.htm#AEAPI-GUID-3CF1D2DD-AEA4-4982-9857-548567AB7169" target="_blank">APEX_EXEC</a> PL/SQL API, the request is logged. This log can be useful for workspace administrators and developers to get a glimpse of all web service requests being done by the workspace. The view APEX_WEBSERVICE_LOG contains the log information.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tB6ylPJUYVjQUn7c6uFgdQ_2WgLCPpgwY9bssz14Z8JLc-RmyZGI_0TLJmiDuWgy6zmmYfjCUJ43VZ3NSeelcnV20JXAbJUn1CkjjOiQSrB5DaZxtGJuSwmaZxiGjcfRAc8Mm3IF0eW1/s1600/Screen+Shot+2018-03-16+at+4.02.59+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="730" data-original-width="1462" height="319" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tB6ylPJUYVjQUn7c6uFgdQ_2WgLCPpgwY9bssz14Z8JLc-RmyZGI_0TLJmiDuWgy6zmmYfjCUJ43VZ3NSeelcnV20JXAbJUn1CkjjOiQSrB5DaZxtGJuSwmaZxiGjcfRAc8Mm3IF0eW1/s640/Screen+Shot+2018-03-16+at+4.02.59+PM.png" width="640" /></a></div>
<br />
<b>Figure 1 - APEX_WEBSERVICE_LOG</b><br />
<br />
As a developer or administrator in a workspace, you can query this view to find the URL, method, request content length, HTTP status code, response content length, the time in seconds between request and response, the date of the request, and the user making the request. To find a description of all the columns in the APEX_WEBSERVICE_LOG view, you can go to the Data Dictionary report in SQL Workshop Utilities.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqxfSxU8L7ACv5f3Xk4yATdr_y3a7he1R9BtUW5-w8_TOLH875Z2_cKJvzS17ASoFJ7-JAwYy1S-C0FnO30-FwHrCdMQtBnI-QqpzqGgzZB0FI7JwDYiiUnUIglsAZwlaD4nvOGk8bG85b/s1600/Screen+Shot+2018-03-16+at+4.04.49+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="709" data-original-width="1444" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqxfSxU8L7ACv5f3Xk4yATdr_y3a7he1R9BtUW5-w8_TOLH875Z2_cKJvzS17ASoFJ7-JAwYy1S-C0FnO30-FwHrCdMQtBnI-QqpzqGgzZB0FI7JwDYiiUnUIglsAZwlaD4nvOGk8bG85b/s640/Screen+Shot+2018-03-16+at+4.04.49+PM.png" width="640" /></a></div>
<br />
<b>Figure 2 - Data Dictionary report for APEX_WEBSERVICE_LOG</b><br />
<br />
The logging of all web service requests is even more useful for administrators of the entire APEX instance. If you are running a hosting business, this log can be used for forensics in case any of your tenants used your service as a launch platform for attacks on other systems. There is a handy interactive report on the log available in Instance Administration - Monitor Activity - Web Service Activity Log.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitZ0KRoSLIe5bZUOZVvULIbkkf5qt-ILwpIcBehViyFvghQbV3QN6UUDk6MsPVkjqOdpDQqPjUrWkbYEXjre5LSOD-SCja8U1tNbIo_mbn-3DkZfzkUopo-75o_x-J3kR7dKIUahClQyTi/s1600/Screen+Shot+2018-03-16+at+4.08.31+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="705" data-original-width="1441" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitZ0KRoSLIe5bZUOZVvULIbkkf5qt-ILwpIcBehViyFvghQbV3QN6UUDk6MsPVkjqOdpDQqPjUrWkbYEXjre5LSOD-SCja8U1tNbIo_mbn-3DkZfzkUopo-75o_x-J3kR7dKIUahClQyTi/s640/Screen+Shot+2018-03-16+at+4.08.31+PM.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<b>Figure 3 - Web Service Activity Log in Internal Administration</b><br />
<br />
By default, there is a log switch every 14 days, so you will have about 28 days of log. If you need to retain information longer than that (or not as long), you can change the default at Internal Administration - Manage Instance - Manage Log Interval.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYAvtw8MF6uqO-OHjdkuk2l7N8QrpkIxH6F5uCwd98FeGnGRpTTOUkukhVxhEs1PU4AcMSApLzHjf09IRq2UZy8Y_d-TfGR0oNNuFwex5QMgydXXuZ9mloWdiJ8_MEFml_0YQ4hYCcxcRf/s1600/Screen+Shot+2018-03-16+at+4.06.52+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="672" data-original-width="1249" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYAvtw8MF6uqO-OHjdkuk2l7N8QrpkIxH6F5uCwd98FeGnGRpTTOUkukhVxhEs1PU4AcMSApLzHjf09IRq2UZy8Y_d-TfGR0oNNuFwex5QMgydXXuZ9mloWdiJ8_MEFml_0YQ4hYCcxcRf/s640/Screen+Shot+2018-03-16+at+4.06.52+PM.png" width="640" /></a></div>
<br />
<b>Figure 4 - Manage Log Interval in Internal Administration</b><br />
<br />
And finally, also handy for hosting or cloud providers, you can set the maximum number of web service requests that each workspace can do in a twenty four hour period. You set the maximum in Internal Administration - Manage Instance - Security - Workspace Isolation.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfiaxWwVIlrvYVoFaC393M8UTUb0jh2w3LyDKpTk0pGhEhbayBnoRpF0QCPfRKVh-jG83QYwxS3TFmF8XlanL_BwXoSoEwNwaymKfjZP15Klwqx1eOOL6gpkqmQtqYFvnEijx-kGT2O0TJ/s1600/Screen+Shot+2018-03-16+at+4.09.27+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="687" data-original-width="1445" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfiaxWwVIlrvYVoFaC393M8UTUb0jh2w3LyDKpTk0pGhEhbayBnoRpF0QCPfRKVh-jG83QYwxS3TFmF8XlanL_BwXoSoEwNwaymKfjZP15Klwqx1eOOL6gpkqmQtqYFvnEijx-kGT2O0TJ/s640/Screen+Shot+2018-03-16+at+4.09.27+PM.png" width="640" /></a></div>
<br />
<br />
<b>Figure 5 - Maximum Web Service Requests in Workspace Isolation</b><br />
<br />
You can also override the instance setting at the workspace level. In internal Administration, go to Existing Workspaces, find the workspace, and click on the workspace name to edit the properties. Set Maximum Web Service Requests under Workspace Isolation.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUWZn6cw02HKiH0afdX_RpollfgJbhw8SO2w-2PNCDtpNLEvw9Inuij8blF1IXflrKDwJRxPZawAiwvJV_FE1cH3B8Jnu5kvaX7JsP3eHS8WRtQgzKNpkL7JRUrg06YDWLjTx1nCib2JSR/s1600/Screen+Shot+2018-03-16+at+4.10.40+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="738" data-original-width="1430" height="330" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUWZn6cw02HKiH0afdX_RpollfgJbhw8SO2w-2PNCDtpNLEvw9Inuij8blF1IXflrKDwJRxPZawAiwvJV_FE1cH3B8Jnu5kvaX7JsP3eHS8WRtQgzKNpkL7JRUrg06YDWLjTx1nCib2JSR/s640/Screen+Shot+2018-03-16+at+4.10.40+PM.png" width="640" /></a></div>
<br />
<br />
<b>Figure 6 - Override ride Maximum Web Service Requests for a Workspace</b><br />
<br />
And there you have it, your 18.1 new feature "nugget," logging web service requests. I hope you find it useful.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-67661647379668031762017-02-03T15:55:00.000-05:002017-02-03T16:09:59.166-05:00Convert Common Oracle Application Express in a CDB to Local APEX in PDBs<h2>
Introduction </h2>
When Oracle Multitenant was released with Oracle Database 12.1.0.1.0 in June 2013, Oracle Application Express was installed by default common in the CDB in CDB$ROOT, PDB$SEED, and all PDBs. In fact, that was the architecture that we recommended at that time. As we have gained experience with multitenant in our internal deployments, we realized that our initial recommendation was wrong. Having APEX installed common locks you in to one version for your entire CDB, and when you need to upgrade APEX, you have to upgrade every PDB, even if that PDB is not using APEX. This would cause unnecessary added time to APEX upgrades.<br />
<br />
Applying the lessons we have learned in our internal deployments, we have been <a href="http://docs.oracle.com/cd/E59726_01/install.50/e39144/db_pluggable.htm#HTMIG29435" target="_blank">recommending</a> that customers remove Oracle Application Express from their CDBs and install APEX locally in PDBs since version 5.0.<br />
<br />
What do you do if you have been using the common APEX from 12.1.0.1.0 or 12.1.0.2.0, and now you want to follow our new recommendation of having APEX installed locally in a PDB? We have been asked that question many times by both internal and external customers. Unfortunately there is no simple answer, no magic SQL script you can run to do the conversion, so we have never really had a good answer.<br />
<br />
Then my manager, <a href="https://twitter.com/joelkallman" target="_blank">Joel Kallman</a>, had a novel idea. He reminded me of the work I did for the Oracle Database Cloud Schema Service, to effectively export almost every single artifact of a workspace, using the command line utility APEXExport, so that a schema service tenant could be moved from one APEX instance to another. This involved greatly expanding our workspace export code, modifying APEXExport to allow for more export options, and then scripting the calls to APEXExport, including creating an installer script to invoke all the exports, and finally zipping the scripts produced. Joel's idea was to reuse this method in a process to convert a CDB where APEX is installed common, to a CDB where APEX is installed locally in PDBs.<br />
<h2>
The Big Idea</h2>
The high level steps to convert common APEX in a CDB to local APEX in PDBs are:<br />
<br />
<ol>
<li>Identify all PDBs in your CDB that have APEX instances</li>
<li>In each PDB, identify all workspaces</li>
<li>Run a script to export all artifacts of all workspaces identified in step 1 into zip files with installers</li>
<li>Completely back up your CDB</li>
<li>Run the APEX removal script to remove APEX from the CDB and all PDBs</li>
<li>Install APEX locally in each PDB identified in step 1. (This may be a good opportunity to upgrade to the latest version!)</li>
<li>Unzip each of your files from setp 3, and run the installer script from each, connected to the appropriate PDB</li>
</ol>
<h2>
The Setup </h2>
I have a 12.1.0.2.0 CDB with two PDBs running APEX. One PDB has multiple workspaces, the other PDB has only one workspace. The CDB is the default APEX 4.2.5.0.00.08 that shipped with 12.1.0.2.0. The workspaces may have SQL scripts uploaded to SQL Workshop, SQL History and Saved SQL that we want to preserve. There are sample and packaged applications that we want to preserve. There are also custom built applications on objects in the schema associated with the workspaces. There are workspace images, and static files that we also want to preserve. I have already completely backed up my CDB.<br />
<h4>
HR Workspace in APEX1 figures</h4>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh88Rn9QuM5zUmnajldBcs8Cqt6FkiPDOe4k65jX9TOn1v2OPeSkVMEU2zB_t_jNazkzyzn-L9s4kcRMGS_X-pTy0IRl-PdTHUyKQqJfJsP5t8tB2WWT1xSgp1lJIFeu89Yb68lV8d4apMG/s1600/Screen+Shot+2017-02-03+at+1.47.03+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="232" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh88Rn9QuM5zUmnajldBcs8Cqt6FkiPDOe4k65jX9TOn1v2OPeSkVMEU2zB_t_jNazkzyzn-L9s4kcRMGS_X-pTy0IRl-PdTHUyKQqJfJsP5t8tB2WWT1xSgp1lJIFeu89Yb68lV8d4apMG/s640/Screen+Shot+2017-02-03+at+1.47.03+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Applications in HR</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtdb1K0aw8-AvXITrxSVXVY2tX0JZj10piet2Nv1OODgAySnJXTFdy9Zp5PqasesIsiRKndy0VYgSBLx2qppW7jBLJfHRBxI_gaUd_vaW7fWQPC0SCtIzIdmIDQj6cLiOXOMH8xoYp8pBZ/s1600/Screen+Shot+2017-02-03+at+1.47.40+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtdb1K0aw8-AvXITrxSVXVY2tX0JZj10piet2Nv1OODgAySnJXTFdy9Zp5PqasesIsiRKndy0VYgSBLx2qppW7jBLJfHRBxI_gaUd_vaW7fWQPC0SCtIzIdmIDQj6cLiOXOMH8xoYp8pBZ/s640/Screen+Shot+2017-02-03+at+1.47.40+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">SQL Script in SQL Workshop</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsIHTv0Pfo-H9-OvRV7I6yk68wSdsGIyYwgRz4h_msdK2bF3KgwbonapS1xiOZQeVAqJcBeW2EqdBk8s9Y3lzdXpXmkV5HkL0HgFu2aKobiSY58P1hGDYNnPDVTb6ew27jiSjgGermRNyG/s1600/Screen+Shot+2017-02-03+at+1.48.31+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="410" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsIHTv0Pfo-H9-OvRV7I6yk68wSdsGIyYwgRz4h_msdK2bF3KgwbonapS1xiOZQeVAqJcBeW2EqdBk8s9Y3lzdXpXmkV5HkL0HgFu2aKobiSY58P1hGDYNnPDVTb6ew27jiSjgGermRNyG/s640/Screen+Shot+2017-02-03+at+1.48.31+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">SQL History in HR</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPQCbZQTnS4BkcAuF0c-UgPIhft7l0FIV4gG0tqJia8NgiOtHdmPUqFj3iOUSycoWYin53Vnpz7irBZ3ioyOW2nQ2waoBkJTBrRMhwbGEUo86nMcb8PhoQQ_tUVR13p4UDg2RLXHePT5ns/s1600/Screen+Shot+2017-02-03+at+1.55.21+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="164" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPQCbZQTnS4BkcAuF0c-UgPIhft7l0FIV4gG0tqJia8NgiOtHdmPUqFj3iOUSycoWYin53Vnpz7irBZ3ioyOW2nQ2waoBkJTBrRMhwbGEUo86nMcb8PhoQQ_tUVR13p4UDg2RLXHePT5ns/s640/Screen+Shot+2017-02-03+at+1.55.21+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Workspace image in HR</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOasprZUsbve1_Z3PA_DydZrZ8qQo0xH-RdozhoIneuDUqUUAF9TIUP7sC8HLBi-Ap4D6CDmm2O1RysKrxPWQVOu26RMnzeaPVJpvfJzTaxjzVlhMI3YKrZZJ14pwvxgoHroob5LGb1qET/s1600/Screen+Shot+2017-02-03+at+1.55.56+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOasprZUsbve1_Z3PA_DydZrZ8qQo0xH-RdozhoIneuDUqUUAF9TIUP7sC8HLBi-Ap4D6CDmm2O1RysKrxPWQVOu26RMnzeaPVJpvfJzTaxjzVlhMI3YKrZZJ14pwvxgoHroob5LGb1qET/s640/Screen+Shot+2017-02-03+at+1.55.56+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Static file in HR</td></tr>
</tbody></table>
<h4>
FINANCE Workspace in APEX1 figures</h4>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifW3FGqr6OW0yeZlEOd9oKU8oF3r_JpFyElJchMszfnF8JE4sU9WRriBFHZKvdVD5UhpqzzMF0C_RvExdMNxgxJLjfS4yJ6pUPSUQH6m_FjC2r0y_q24Wo6D71rQmGhnNFTcyafl9wo5bF/s1600/Screen+Shot+2017-02-03+at+1.53.42+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifW3FGqr6OW0yeZlEOd9oKU8oF3r_JpFyElJchMszfnF8JE4sU9WRriBFHZKvdVD5UhpqzzMF0C_RvExdMNxgxJLjfS4yJ6pUPSUQH6m_FjC2r0y_q24Wo6D71rQmGhnNFTcyafl9wo5bF/s640/Screen+Shot+2017-02-03+at+1.53.42+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Applications in FINANCE workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_mSkv1RMUwGatbAfqMsBmiPF9xRM441qdyuSNwoHn-63I03u78-PTZxeIFblXF8ite6lOCcSyjpj2hKHNiM9H4dD3gWHb-RJbhO05QskVjdFVyyWIg6ab3oB2n4VsPX9l8MlFB4P_b0HZ/s1600/Screen+Shot+2017-02-03+at+1.54.43+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="378" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_mSkv1RMUwGatbAfqMsBmiPF9xRM441qdyuSNwoHn-63I03u78-PTZxeIFblXF8ite6lOCcSyjpj2hKHNiM9H4dD3gWHb-RJbhO05QskVjdFVyyWIg6ab3oB2n4VsPX9l8MlFB4P_b0HZ/s640/Screen+Shot+2017-02-03+at+1.54.43+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Saved SQL in SQL Workshop</td></tr>
</tbody></table>
<br />
<h4>
MARKETING Workspace in APEX2 figures</h4>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmQn6h6Oskq3vTHmIRNz2-t-YVpClZeM89EmXputVzTzk2QqFoKsRstEnM6EnDC3iEEhmA_oxgHWgTUVRRmqRy1w9WVRumJ2BCDaWCoDU3jhJ8VLVOEwaQwO4PRuxXlk6CgkPAuvOrnJ_i/s1600/Screen+Shot+2017-02-03+at+1.57.03+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="332" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmQn6h6Oskq3vTHmIRNz2-t-YVpClZeM89EmXputVzTzk2QqFoKsRstEnM6EnDC3iEEhmA_oxgHWgTUVRRmqRy1w9WVRumJ2BCDaWCoDU3jhJ8VLVOEwaQwO4PRuxXlk6CgkPAuvOrnJ_i/s640/Screen+Shot+2017-02-03+at+1.57.03+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Applications in MARKETING workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzn_zwTk7aWMPcCOrX8YKcY5Qwei1KIjQLqNUhGpY2dBj4VMYh3vE7ZtZMOq1m_EDfdQrdcVz3k5H3x7ZAiYMqwKia5oHI6UNMDQYxqZO3tj3kR9-ytud53mB6m68t7lgrS3gmc_PijtrE/s1600/Screen+Shot+2017-02-03+at+1.57.36+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzn_zwTk7aWMPcCOrX8YKcY5Qwei1KIjQLqNUhGpY2dBj4VMYh3vE7ZtZMOq1m_EDfdQrdcVz3k5H3x7ZAiYMqwKia5oHI6UNMDQYxqZO3tj3kR9-ytud53mB6m68t7lgrS3gmc_PijtrE/s640/Screen+Shot+2017-02-03+at+1.57.36+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Workspace Images in MARKETING workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieRsph9epE12zl4G5osedCR3fxP_yRvuBXdRhEPItZF9lKnIUld439r8bqTqVOM0MZkq2i3DClB1N23yP0VjEA-csgJLaypukIsBdl4bjFYrEvPNB4YCsgOczMQnZVk7I7-Agr8SqaXMvh/s1600/Screen+Shot+2017-02-03+at+1.58.31+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieRsph9epE12zl4G5osedCR3fxP_yRvuBXdRhEPItZF9lKnIUld439r8bqTqVOM0MZkq2i3DClB1N23yP0VjEA-csgJLaypukIsBdl4bjFYrEvPNB4YCsgOczMQnZVk7I7-Agr8SqaXMvh/s640/Screen+Shot+2017-02-03+at+1.58.31+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Saved SQL in SQL Workshop</td></tr>
</tbody></table>
<h2>
The Hook</h2>
<h4>
Identify all PDBs that have APEX instances</h4>
<span style="font-family: "Courier New",Courier,monospace;">SQL> select p.pdb_name, r.version, r.status from sys.dba_pdbs p, sys.cdb_registry r where p.pdb_id = r.con_id and r.comp_id = 'APEX' order by 1;<br /><br />PDB_NAME VERSION STATUS<br />------------------------------ ------------------------------ -----------<br />APEX1 4.2.5.00.08 VALID<br />APEX2 4.2.5.00.08 VALID</span><br />
<br />
<h4>
Identify all workspaces</h4>
<span style="font-family: "Courier New",Courier,monospace;">SQL> set num 40 <br />SQL> alter session set container=APEX1;<br /><br />Session altered.<br /><br />SQL> select workspace_id from apex_workspaces where workspace_id > 100;<br /><br /> WORKSPACE_ID<br />----------------------------------------<br /> 2222525459993115<br /> 2336806112004961<br /><br />SQL> alter session set container=APEX2;<br /><br />Session altered.<br /><br />SQL> select workspace_id from apex_workspaces where workspace_id > 100;<br /><br /> WORKSPACE_ID<br />----------------------------------------<br /> 2224405822867543</span><br />
<h4>
Run a script to export all artifacts</h4>
The original script that I wrote was in C shell and did the job, but my colleague <a href="https://twitter.com/vuvarovs" target="_blank">Vlad Uvarov</a> rewrote it in bash (apparently anyone under 40 no longer uses C shell) and vastly improved it. A slightly revised version of the script is listed below.<br />
<br />
<pre class="sql" name="code">#!/bin/bash -e
THIS_SCRIPT=$(basename "$0" )
THIS_DIR=$(cd "$(dirname "$0" )" && pwd )
CURRENT_DIR=$(pwd )
# ===================================================================================
# Function that displays script usage instructions and terminates the script
#
f_usage () {
cat <<EOF
Usage: $THIS_SCRIPT <JDBC connection string> <user> <password> <workspace ID>
Parameters:
JDBC connection string Database connection URL in JDBC format
user Database username
password Password of the database user
workspace ID ID of the workspace to be exported
Example:
./$THIS_SCRIPT //apex.example.com:1521/orcl apex_040200 secret 1234567890
EOF
exit 1
}
# ===================================================================================
# First, check environment variables and input parameters
#
[ -z "$ORACLE_HOME" ] && echo "Error: ORACLE_HOME environment variable is not set." && exit 1
JAVA_EXE=$ORACLE_HOME/jdk/bin/java
[ ! -x "$JAVA_EXE" ] && echo "Error: Java executable not found ($JAVA_EXE)." && exit 1
OJDBC_JAR=$ORACLE_HOME/jdbc/lib/ojdbc6.jar
[ ! -f "$OJDBC_JAR" ] && echo "Error: Oracle JDBC library not found ($OJDBC_JAR)." && exit 1
APEXEXPORT=$ORACLE_HOME/apex/utilities/oracle/apex/APEXExport.class
[ ! -f "$THIS_DIR/$APEXEXPORT" -a ! -f "$APEXEXPORT" ] && echo "Error: Missing APEXExport utility ($APEXEXPORT)." && exit 1
(( $# < 4 )) && echo "Error: This script requires 4 parameters." && echo && f_usage
# ===================================================================================
# Step 1: Export APEX workspace, including applications and files
#
EXP_DIR=$(mktemp -d ${TMPDIR:-/tmp}/$(basename "$THIS_SCRIPT" .sh ).XXXXXX )
cd "$EXP_DIR"
cat <<EOF
Oracle Application Express workspace export
Using ORACLE_HOME=$ORACLE_HOME
EOF
$JAVA_EXE -version
echo
CP=$OJDBC_JAR:$THIS_DIR:$ORACLE_HOME/apex/utilities
if [ "$THIS_DIR" != "$CURRENT_DIR" ]; then
CP=$CP:$CURRENT_DIR
fi
$JAVA_EXE -cp $CP oracle.apex.APEXExport -db "$1" -user "$2" -password "$3" -workspaceid "$4" -expWorkspace -expTeamdevdata
$JAVA_EXE -cp $CP oracle.apex.APEXExport -db "$1" -user "$2" -password "$3" -workspaceid "$4" -expFiles
$JAVA_EXE -cp $CP oracle.apex.APEXExport -db "$1" -user "$2" -password "$3" -workspaceid "$4" -expLocked -expSavedReports
# ===================================================================================
# Step 2: Create ZIP archive with a generated installation script and all export files
#
INSTALL_SCRIPT=install_${4}.sql
cat > "$INSTALL_SCRIPT" <<EOF
prompt
spool install_${4}.log
prompt Oracle Application Express workspace export
prompt Workspace ID $4 exported on $(date )
alter session set current_schema = APEX_050100;
@@w${4}.sql
EOF
for f in *.sql; do
if [ "$f" != "w${4}.sql" -a "$f" != "$INSTALL_SCRIPT" ]; then
echo "@@$f" >> "$INSTALL_SCRIPT"
fi
done
cat >> "$INSTALL_SCRIPT" <<EOF
spool off
prompt
exit
EOF
echo
ZIP_FILE="$CURRENT_DIR/install_${4}_$(date +%Y%m%d ).zip"
rm -f "$ZIP_FILE"
zip -9 "$ZIP_FILE" *.sql
echo
echo "Generated $ZIP_FILE"
echo
# ===================================================================================
# Step 3: Clean up
#
cd "$CURRENT_DIR"
rm -rf "$EXP_DIR"
</pre>
workspace_export.sh<br />
<br />
One thing to note in the script above is that the install script being generated assumes that APEX 5.1 is installed in your target APEX instance. If that is not your plan, change the line "alter session set current_schema = APEX_050100" to match the APEX schema of the version you plan to install locally in your PDBs.<br />
<br />
Also, for convenience, I am going to temporarily unlock APEX_040200 in my CDB and set a known password, and pass those necessary credentials to the workspace_export.sh script. You could really use any database user that has been granted the APEX_ADMINISTRATOR_ROLE.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter user apex_040200 account unlock identified by oracle container=all;<br /><br />User altered.</span><br />
<br />
I saved the script above in a directory where I want all my zip files to end up. Now I will call the script passing each of the workspace IDs I identified in the previous step.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ ./workspace_export.sh //localhost:1521/APEX1 APEX_040200 oracle 2222525459993115<br />Oracle Application Express workspace export<br /><br />Using ORACLE_HOME=/scratch/jstraub/app/product/12.1.0/dbhome_1<br />java version "1.6.0_75"<br />Java(TM) SE Runtime Environment (build 1.6.0_75-b13)<br />Java HotSpot(TM) 64-Bit Server VM (build 20.75-b01, mixed mode)<br /><br />Exporting Workspace 2222525459993115:'HR' <br /> Completed at Fri Feb 03 08:29:07 PST 2017<br />Exporting Application 100:'Sample Database Application' <br /> Completed at Fri Feb 03 08:29:16 PST 2017<br />Exporting Application 102:'Checklist Manager' <br /> Completed at Fri Feb 03 08:29:17 PST 2017<br />Exporting Application 103:'EMPLOYEES' <br /> Completed at Fri Feb 03 08:29:18 PST 2017<br />Exporting Application 104:'Sample Websheet Application - Big Cats' <br /> Completed at Fri Feb 03 08:29:18 PST 2017<br /><br /> adding: f100.sql (deflated 88%)<br /> adding: f102.sql (deflated 89%)<br /> adding: f103.sql (deflated 93%)<br /> adding: files_2222525459993115.sql (deflated 55%)<br /> adding: install_2222525459993115.sql (deflated 39%)<br /> adding: w2222525459993115.sql (deflated 87%)<br /> adding: ws104.sql (deflated 64%)<br /><br />Generated /scratch/jstraub/cdbconvertapex/install_2222525459993115_20170203.zip</span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ ./workspace_export.sh //localhost:1521/APEX1 APEX_040200 oracle 2336806112004961<br />Oracle Application Express workspace export<br /><br />Using ORACLE_HOME=/scratch/jstraub/app/product/12.1.0/dbhome_1<br />java version "1.6.0_75"<br />Java(TM) SE Runtime Environment (build 1.6.0_75-b13)<br />Java HotSpot(TM) 64-Bit Server VM (build 20.75-b01, mixed mode)<br /><br />Exporting Workspace 2336806112004961:'FINANCE' <br /> Completed at Fri Feb 03 10:17:59 PST 2017<br />Exporting Application 101:'Sample Database Application' <br /> Completed at Fri Feb 03 10:18:13 PST 2017<br />Exporting Application 105:'Group Calendar' <br /> Completed at Fri Feb 03 10:18:14 PST 2017<br />Exporting Application 106:'QUOTES' <br /> Completed at Fri Feb 03 10:18:14 PST 2017<br /><br /> adding: f101.sql (deflated 88%)<br /> adding: f105.sql (deflated 89%)<br /> adding: f106.sql (deflated 93%)<br /> adding: files_2336806112004961.sql (deflated 64%)<br /> adding: install_2336806112004961.sql (deflated 39%)<br /> adding: w2336806112004961.sql (deflated 82%)<br /><br />Generated /scratch/jstraub/cdbconvertapex/install_2336806112004961_20170203.zip</span><br />
<br />
And then for the other PDB, APEX2, we pass a different connect string:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ ./workspace_export.sh //localhost:1521/APEX2 APEX_040200 oracle 2224405822867543<br />Oracle Application Express workspace export<br /><br />Using ORACLE_HOME=/scratch/jstraub/app/product/12.1.0/dbhome_1<br />java version "1.6.0_75"<br />Java(TM) SE Runtime Environment (build 1.6.0_75-b13)<br />Java HotSpot(TM) 64-Bit Server VM (build 20.75-b01, mixed mode)<br /><br />Exporting Workspace 2224405822867543:'MARKETING' <br /> Completed at Fri Feb 03 10:20:04 PST 2017<br />Exporting Application 100:'Sample Database Application' <br /> Completed at Fri Feb 03 10:20:13 PST 2017<br />Exporting Application 101:'Sample Websheet Application - AnyCo IT Department' <br /> Completed at Fri Feb 03 10:20:13 PST 2017<br />Exporting Application 102:'PROJECT_TASKS' <br /> Completed at Fri Feb 03 10:20:14 PST 2017<br />Exporting Application 103:'Decision Manager' <br /> Completed at Fri Feb 03 10:20:14 PST 2017<br />Exporting Application 104:'P-Track' <br /> Completed at Fri Feb 03 10:20:17 PST 2017<br /><br /> adding: f100.sql (deflated 88%)<br /> adding: f102.sql (deflated 93%)<br /> adding: f103.sql (deflated 89%)<br /> adding: f104.sql (deflated 89%)<br /> adding: files_2224405822867543.sql (deflated 54%)<br /> adding: install_2224405822867543.sql (deflated 40%)<br /> adding: w2224405822867543.sql (deflated 82%)<br /> adding: ws101.sql (deflated 58%)<br /><br />Generated /scratch/jstraub/cdbconvertapex/install_2224405822867543_20170203.zip</span><br />
<h2>
The long game</h2>
I have a complete backup of my database, and I have all the zip files that will reconstruct my workspaces. It is time to do the actual conversion.<br />
<h4>
Remove APEX from the CDB and all PDBs</h4>
<span style="font-family: "Courier New",Courier,monospace;">Connected to:<br />Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production<br />With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options<br /><br />SQL> @apxremov_con.sql<br /><br />PL/SQL procedure successfully completed.<br /><br />Performing installation in multitenant container database in the background.<br />The installation progress is spooled into apxremov*_con*.log files.<br /><br />Please wait...<br /><br />catcon: ALL catcon-related output will be written to apxremov1_con_catcon_9311.lst<br />catcon: See apxremov1_con*.log files for output generated by scripts<br />catcon: See apxremov1_con_*.lst files for spool files, if any<br />catcon.pl: completed successfully<br /><br />catcon: ALL catcon-related output will be written to apxremov2_con_catcon_9723.lst<br />catcon: See apxremov2_con*.log files for output generated by scripts<br />catcon: See apxremov2_con_*.lst files for spool files, if any<br />catcon.pl: completed successfully<br /><br /><br />Installation completed. Log files for each container can be found in:<br /><br />apxremov*_con*.log<br /><br />You can quickly scan for ORA errors or compilation errors by using a utility<br />like grep:<br /><br />grep ORA- *.log<br />grep PLS- *.log</span> <br />
<h4>
Install APEX 5.1 locally in the PDBs</h4>
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter session set container=APEX1;<br /><br />Session altered.<br /><br />SQL> @apexins.sql SYSAUX SYSAUX TEMP /i/</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> @apex_rest_config.sql</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> @apxchpwd.sql</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> @apex_epg_config.sql /scratch/jstraub/apx51 -- only if you are using EPG, very doubtful</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter session set container=APEX2;<br /><br />Session altered.<br /><br />SQL> @apexins.sql SYSAUX SYSAUX TEMP /i/</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> @apex_rest_config.sql</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> @apxchpwd.sql</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> @apex_epg_config.sql /scratch/jstraub/apx51 -- only if you are using EPG, very doubtful</span><br />
<h4>
Recreate the workspaces using the generated zip files</h4>
First, I am again going to temporarily unlock and change the password for the APEX database user, in this case APEX_050100. Since now APEX_050100 is a local user to the PDB, I have to do it in both APEX1 and APEX2 PDBs.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter session set container=APEX1;<br /><br />Session altered.</span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter user APEX_050100 account unlock identified by oracle;<br /><br />User altered.</span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter session set container=APEX2;<br /><br />Session altered.<br /><br />SQL> alter user APEX_050100 account unlock identified by oracle;<br /><br />User altered.</span><br />
<br />
Then I unzip each complete workspace export and run the corresponding install script.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ mkdir hr</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ unzip install_2222525459993115_20170203.zip -d hr</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ cd hr </span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv hr]$ sqlplus apex_050100/oracle@localhost/APEX1<br /><br />SQL*Plus: Release 12.1.0.2.0 Production on Fri Feb 3 12:05:24 2017<br /><br />Copyright (c) 1982, 2014, Oracle. All rights reserved.<br /><br /><br />Connected to:<br />Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production<br />With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options<br /><br />SQL> @install_2222525459993115.sql </span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ mkdir finance</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ unzip install_2336806112004961_20170203.zip -d finance</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ cd finance</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv finance]$ sqlplus apex_050100/oracle@localhost/APEX1<br /><br />SQL*Plus: Release 12.1.0.2.0 Production on Fri Feb 3 12:14:21 2017<br /><br />Copyright (c) 1982, 2014, Oracle. All rights reserved.<br /><br />Last Successful login time: Fri Feb 03 2017 12:05:24 -08:00<br /><br />Connected to:<br />Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production<br />With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options<br /><br />SQL> @install_2336806112004961.sql </span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ mkdir marketing</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv cdbconvertapex]$ unzip install_2224405822867543_20170203.zip -d marketing</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[jstraub@slc02otv marketing]$ sqlplus apex_050100/oracle@localhost/APEX2<br /><br />SQL*Plus: Release 12.1.0.2.0 Production on Fri Feb 3 12:16:11 2017<br /><br />Copyright (c) 1982, 2014, Oracle. All rights reserved.<br /><br /><br />Connected to:<br />Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production<br />With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options<br /><br />SQL> @install_2224405822867543.sql</span><br />
<br />
Now we login to each workspace and check that all the artifacts from the workspace migrated over.<br />
<h4>
HR workspace in APEX1 figures - APEX 5.1</h4>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbjyOESserjRSX87WAUu5VagYOFR4XM-J4tldjuMk35dwnmyWjFIZeFbHJuRUa2TeOxcsWgr_6Ji2kmu04DhX-fYoVy_RaJgTyWp_EcQVmR5UossOJ3s0bLlS3Xtst_12sRL9wDa1mJbJJ/s1600/Screen+Shot+2017-02-03+at+3.22.22+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbjyOESserjRSX87WAUu5VagYOFR4XM-J4tldjuMk35dwnmyWjFIZeFbHJuRUa2TeOxcsWgr_6Ji2kmu04DhX-fYoVy_RaJgTyWp_EcQVmR5UossOJ3s0bLlS3Xtst_12sRL9wDa1mJbJJ/s640/Screen+Shot+2017-02-03+at+3.22.22+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Applications in HR Workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcWrnmxh2aH4XP_o6dMTau1RcMhDUUxyDGtOHkaU1ATpjizMJeghv_GRRRLfYbN48J-x4TTmPVdpOHX4uB-n2pSsCKuA4PCFDoJepOGYKmv_bg-gvkM8jcnRf0yLjvu7kjgkB0Q3fCThkm/s1600/Screen+Shot+2017-02-03+at+3.26.26+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcWrnmxh2aH4XP_o6dMTau1RcMhDUUxyDGtOHkaU1ATpjizMJeghv_GRRRLfYbN48J-x4TTmPVdpOHX4uB-n2pSsCKuA4PCFDoJepOGYKmv_bg-gvkM8jcnRf0yLjvu7kjgkB0Q3fCThkm/s640/Screen+Shot+2017-02-03+at+3.26.26+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Static Files and Images in HR Workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgU5b9sUtO4z9eEn3aRxDJZ5MwAqa1njevO7Wa115Dz6bM5H0M0_pZh3O9SFwsOXdtxdnjUuaNKL8kzoz2OQsEGC9wwBf7lJiY2dRh5htRy3NWlpD93yaWegBJMjlKwwQp_E4fPZkE24QK/s1600/Screen+Shot+2017-02-03+at+3.27.00+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgU5b9sUtO4z9eEn3aRxDJZ5MwAqa1njevO7Wa115Dz6bM5H0M0_pZh3O9SFwsOXdtxdnjUuaNKL8kzoz2OQsEGC9wwBf7lJiY2dRh5htRy3NWlpD93yaWegBJMjlKwwQp_E4fPZkE24QK/s640/Screen+Shot+2017-02-03+at+3.27.00+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">SQL Script in SQL Workshop</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMb_G-8pCKYx51WlIhHo5INfAbLNOfwxHLQ8IHjrX5etkMVwgOWtZNJj5yoR1KyAAfrpPv4eK3I8Ay9owWFgoh73E3fBVndfL5K-KugxjmrEertMVShD9cdohbD5oX3xzG3YrOPvKlx8Su/s1600/Screen+Shot+2017-02-03+at+3.27.39+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="140" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMb_G-8pCKYx51WlIhHo5INfAbLNOfwxHLQ8IHjrX5etkMVwgOWtZNJj5yoR1KyAAfrpPv4eK3I8Ay9owWFgoh73E3fBVndfL5K-KugxjmrEertMVShD9cdohbD5oX3xzG3YrOPvKlx8Su/s640/Screen+Shot+2017-02-03+at+3.27.39+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">SQL History in SQL Workshop</td></tr>
</tbody></table>
<h4>
FINANCE workspace in APEX1 figures - APEX 5.1</h4>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNnsCkzq3XhSC_GjrrojcaVcEGBqOv-detiMngfzIP-FcDzRu3WHG2Ps6k_faKDqEvrONtn-NlfYbgf523QwJHQcjXgDo9NOPv3jxyZV_adDxnRtmlSbJ55ieKSj8nK3inL0n0j7kVBEf3/s1600/Screen+Shot+2017-02-03+at+3.29.17+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNnsCkzq3XhSC_GjrrojcaVcEGBqOv-detiMngfzIP-FcDzRu3WHG2Ps6k_faKDqEvrONtn-NlfYbgf523QwJHQcjXgDo9NOPv3jxyZV_adDxnRtmlSbJ55ieKSj8nK3inL0n0j7kVBEf3/s640/Screen+Shot+2017-02-03+at+3.29.17+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Applications in FINANCE Workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU6-qIA2AomasUl9ynoKOpnUY1mPr4YiEy481DUho9UDqHyHBtD3H4EYT2MP-qC6S5oHhsEV7N8NWtnRP2zuHIeVdRj93J3lpJA8Q6_mBXpQiJgzzx2N5CMwZhN5xT_6npJimwR963RYbq/s1600/Screen+Shot+2017-02-03+at+3.30.03+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU6-qIA2AomasUl9ynoKOpnUY1mPr4YiEy481DUho9UDqHyHBtD3H4EYT2MP-qC6S5oHhsEV7N8NWtnRP2zuHIeVdRj93J3lpJA8Q6_mBXpQiJgzzx2N5CMwZhN5xT_6npJimwR963RYbq/s640/Screen+Shot+2017-02-03+at+3.30.03+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Saved SQL in SQL Workshop</td></tr>
</tbody></table>
<h4>
MARKETING workspace in APEX2 figures - APEX 5.1</h4>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-080dbWBuNqhLDYWPlLLeCyiC0mweYDxazEYyRFY-scN0RkVaNkg_TErdUf-Ro_4JnPgf_KT4EKWIeC3vD5oHgekwru5e77wwEd4pRy_G8FLPZs5rSgMOwglF5mFRX1R0fbez1Wdb7FEg/s1600/Screen+Shot+2017-02-03+at+3.31.20+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-080dbWBuNqhLDYWPlLLeCyiC0mweYDxazEYyRFY-scN0RkVaNkg_TErdUf-Ro_4JnPgf_KT4EKWIeC3vD5oHgekwru5e77wwEd4pRy_G8FLPZs5rSgMOwglF5mFRX1R0fbez1Wdb7FEg/s640/Screen+Shot+2017-02-03+at+3.31.20+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Applications in MARKETING Workspace</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEnCovAmO3MLTQCnoBsMEYA8WpYiHGQXPbDXigTm7d8XfOk5DFfcWgaDX9TzrjuJ8yE_-K-i8fu8Y067n6NAgqmIVXRjzG7o1kUZrFILs9mrEQr8MnI0l_0xAY8yApsOcmuUBeVaYw5BeP/s1600/Screen+Shot+2017-02-03+at+3.32.02+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEnCovAmO3MLTQCnoBsMEYA8WpYiHGQXPbDXigTm7d8XfOk5DFfcWgaDX9TzrjuJ8yE_-K-i8fu8Y067n6NAgqmIVXRjzG7o1kUZrFILs9mrEQr8MnI0l_0xAY8yApsOcmuUBeVaYw5BeP/s640/Screen+Shot+2017-02-03+at+3.32.02+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Static Workspace Files in MARKETING</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggMTuvvdlvtCuHBf1zE9UBGBEjFdQIP-Ej9ZCUgo4QWnTUsV9ifDYrgqzvPJpg6aUqyTiyXULXiDp9tOO718CSVZviKEJl9GTZTxVIndkc7QdOnJ9KQIgh9JjviYBKVFaZ2T9rEwuVyQYU/s1600/Screen+Shot+2017-02-03+at+3.32.39+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="120" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggMTuvvdlvtCuHBf1zE9UBGBEjFdQIP-Ej9ZCUgo4QWnTUsV9ifDYrgqzvPJpg6aUqyTiyXULXiDp9tOO718CSVZviKEJl9GTZTxVIndkc7QdOnJ9KQIgh9JjviYBKVFaZ2T9rEwuVyQYU/s640/Screen+Shot+2017-02-03+at+3.32.39+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Saved SQL in SQL Workshop</td></tr>
</tbody></table>
<h2>
One more thing</h2>
Actually, two more things. First, this process will not bring over "Template Applications" and "Public Themes." These features are not well known and rarely used, but you can easily determine if you have them by logging into internal administration, click on Manage Instance, and then click the Public Themes and Template Applications links. If there are applications in either area, simply export them, and them import them into internal administration after you recreate your workspaces.<br />
<br />
Second, you may want to create another PDB, call it APEX51SEED, and install APEX into it. Put the PDB in read only mode, and then when you create a new PDB, you can create it from APEX51SEED and it will already have APEX 5.1 installed locally. In our case, we could not use this method to install APEX only once, because we needed the schemas that were in our APEX1 and APEX2 PDBs.<br />
<h2>
Conclusion</h2>
Having APEX installed locally in PDBs provides greater flexibility in your CDB, reduces upgrade time, and as well simplifies unplug/plug operations of your PDBs between CDBs. If you have a CDB where APEX is installed common, and you are using APEX in some or all of those PDBs, it is possible to do an in-place conversion using the method described above. Unfortunately, there is no magic SQL or script that can simplify this process. I hope you are successful if you go down this path, but be sure you have a complete backup of your CDB before trying. You can also use parts of this method to simply move a workspace from one APEX instance to another. That would require you to also move the schema, using datapump or another utility.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com1tag:blogger.com,1999:blog-6139250371277978964.post-30859970761656094492017-01-06T15:58:00.001-05:002017-02-03T09:03:13.604-05:00Ooops... I did it again.APEX 5.1 is released! As Shaun points out at this forum <a href="https://community.oracle.com/thread/4004143" target="_blank">post</a>, the appendix of the Oracle Application Express 5.1 Installation Guide is missing instructions to downgrade back to 5.0, after a failed upgrade attempt.<br />
<br />
My bad. I signed off on the Oracle Application Express Installation Guide as being complete for 5.1. Unfortunately, I did not pay enough attention to the appendix. We will get this corrected soon in a refreshed version of the Installation Guide, but in the meantime, below are the instructions we will be including. <br />
<br />
<br />
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 4;">
<b><span style="font-family: "times"; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Reverting
to Release 5.0 in a non-CDB</span></b></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "times"; font-size: 10.0pt;">To
revert to a previous Oracle Application Express release 5.0 in a non-CDB:</span></div>
<ol start="1" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">If you altered your images directory, revert it back to
the release you want to revert to. See "</span><a href="https://docs.oracle.com/database/apex-5.1/HTMIG/cleaningup-after-failed-installation.htm#GUID-E91839C4-E18A-4562-B975-C04EC1C5D614"><span style="color: blue; font-family: "times"; font-size: 10.0pt;">Reverting the Images
Directory</span></a><span style="font-family: "times"; font-size: 10.0pt;">."</span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Change your working directory to </span><span style="font-family: "courier"; font-size: 10.0pt;">apex/core</span><span style="font-family: "times"; font-size: 10.0pt;"> in the 5.0 source.</span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Start SQL*Plus and connect to the database where Oracle
Application Express is installed as SYS specifying the SYSDBA role: <br /> </span></li>
</ol>
<div class="MsoNormal" style="margin-left: .5in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "times"; font-size: 10.0pt;">On Windows:</span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">SYSTEM_DRIVE:\
sqlplus /nolog </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">SQL>
CONNECT SYS as SYSDBA </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">Enter
password: SYS_password </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "times"; font-size: 10.0pt;">On UNIX and Linux:</span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">$
sqlplus /nolog </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">SQL>
CONNECT SYS as SYSDBA </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">Enter
password: SYS_password </span></div>
<ol start="4" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Execute the following commands: </span></li>
</ol>
<pre class="sql" name="code">alter session set current_schema = SYS;
@wwv_flow_val.sql
@wwv_flow_val.plb
begin
dbms_utility.compile_schema('APEX_050000');
end;
/
set define '^'
@validate_apex x x APEX_050000
begin
for i in ( select owner, trigger_name
from sys.dba_triggers
where owner = 'APEX_050000'
and trigger_name like 'WWV_FLOW_UPGRADE_%'
order by 1 )
loop
sys.dbms_output.put_line('Dropping trigger '||i.owner||'.'||i.trigger_name);
execute immediate 'drop trigger '||i.owner||'.'||i.trigger_name;
end loop;
end;
/
ALTER SESSION SET CURRENT_SCHEMA = APEX_050000;
exec apex_050000.wwv_flow_upgrade.switch_schemas('APEX_050100','APEX_050000');
ALTER SESSION SET CURRENT_SCHEMA = SYS;
drop context APEX$SESSION;
create context APEX$SESSION using APEX_050000.WWV_FLOW_SESSION_CONTEXT;
declare
l_apex_version varchar2(30);
l_schemas sys.dbms_registry.schema_list_t;
begin
l_apex_version := apex_050000.wwv_flows_release;
dbms_registry.downgrading('APEX','Oracle Application Express','validate_apex','APEX_050000');
dbms_registry.downgraded('APEX',l_apex_version);
select username
bulk collect into l_schemas
from all_users
where username in ('FLOWS_FILES','APEX_PUBLIC_USER','APEX_LISTENER','APEX_REST_PUBLIC_USER','APEX_INSTANCE_ADMIN_USER')
order by 1;
sys.dbms_registry.update_schema_list('APEX', l_schemas);
validate_apex;
end;
/
</pre>
<ol start="5" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">See the next section, "</span><a href="https://docs.oracle.com/database/apex-5.1/HTMIG/cleaningup-after-failed-installation.htm#GUID-E7A956E1-00F8-44F5-B92F-6628514D2DF0"><span style="color: blue; font-family: "times"; font-size: 10.0pt;">Removing the Oracle
Application Express Release 5.1 Schema</span></a><span style="font-family: "times"; font-size: 10.0pt;">."</span></li>
</ol>
<br />
<span style="font-family: "times"; font-size: 10.0pt;">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Times;
panose-1:2 0 5 0 0 0 0 0 0 0;
mso-font-charset:0;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 0 0 0 1 0;}
@font-face
{font-family:"MS 明朝";
mso-font-charset:78;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:1 134676480 16 0 131072 0;}
@font-face
{font-family:"MS 明朝";
mso-font-charset:78;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:1 134676480 16 0 131072 0;}
@font-face
{font-family:Cambria;
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:-536870145 1073743103 0 0 415 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Cambria;
mso-ascii-font-family:Cambria;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"MS 明朝";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Cambria;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-family:Cambria;
mso-ascii-font-family:Cambria;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"MS 明朝";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Cambria;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:762381365;
mso-list-template-ids:893558188;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
</style>
</span><br />
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 4;">
<span style="font-family: "times"; font-size: normal;"><b><span style="font-family: "times"; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Reverting
to Release 5.0 in a CDB</span></b></span></div>
<span style="font-family: "times"; font-size: 10.0pt;">
</span><br />
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "times"; font-size: 10.0pt;"><span style="font-family: "times"; font-size: 10.0pt;">To
revert to a previous Oracle Application Express release 5.0 in a CDB:</span></span></div>
<span style="font-family: "times"; font-size: 10.0pt;">
</span>
<ol start="1" type="1"><span style="font-family: "times"; font-size: 10.0pt;">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">If you altered your images directory, revert it back to
the release you want to revert to. See "</span><a href="https://docs.oracle.com/database/apex-5.1/HTMIG/cleaningup-after-failed-installation.htm#GUID-E91839C4-E18A-4562-B975-C04EC1C5D614"><span style="color: blue; font-family: "times"; font-size: 10.0pt;">Reverting the Images
Directory</span></a><span style="font-family: "times"; font-size: 10.0pt;">."</span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Change your working directory to </span><span style="font-family: "courier"; font-size: 10.0pt;">apex/core</span><span style="font-family: "times"; font-size: 10.0pt;"> in the 5.0 source.</span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Create a new text file in that directory named </span><span style="font-family: "courier"; font-size: 10.0pt;">apx50dgrd1.sql</span><span style="font-family: "times"; font-size: 10.0pt;"> consisting of the following: </span></li>
</span></ol>
<span style="font-family: "times"; font-size: 10.0pt;">
<pre class="sql" name="code">alter session set current_schema = SYS;
@wwv_flow_val.sql
@wwv_flow_val.plb
begin
dbms_utility.compile_schema('APEX_050000');
end;
/
set define '^'
@validate_apex x x APEX_050000
begin
for i in ( select owner, trigger_name
from sys.dba_triggers
where owner = 'APEX_050000'
and trigger_name like 'WWV_FLOW_UPGRADE_%'
order by 1 )
loop
sys.dbms_output.put_line('Dropping trigger '||i.owner||'.'||i.trigger_name);
execute immediate 'drop trigger '||i.owner||'.'||i.trigger_name;
end loop;
end;
/
ALTER SESSION SET CURRENT_SCHEMA = APEX_050000;
exec apex_050000.wwv_flow_upgrade.switch_schemas('APEX_050100','APEX_050000');
ALTER SESSION SET CURRENT_SCHEMA = SYS;
drop context APEX$SESSION;
create context APEX$SESSION using APEX_050000.WWV_FLOW_SESSION_CONTEXT;
declare
l_apex_version varchar2(30);
l_schemas sys.dbms_registry.schema_list_t;
begin
l_apex_version := apex_050000.wwv_flows_release;
dbms_registry.downgrading('APEX','Oracle Application Express','validate_apex','APEX_050000');
dbms_registry.downgraded('APEX',l_apex_version);
select username
bulk collect into l_schemas
from all_users
where username in ('FLOWS_FILES','APEX_PUBLIC_USER','APEX_LISTENER','APEX_REST_PUBLIC_USER','APEX_INSTANCE_ADMIN_USER')
order by 1;
sys.dbms_registry.update_schema_list('APEX', l_schemas);
validate_apex;
end;
/
</pre>
<ol start="4">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Create a second new text file in that directory named </span><span style="font-family: "courier"; font-size: 10.0pt;">apx50dgrd.sql</span><span style="font-family: "times"; font-size: 10.0pt;"> consisting of the following: </span></li>
</ol>
<pre class="sql" name="code">set define '^'
whenever sqlerror exit
column :xe_home new_value OH_HOME NOPRINT
variable xe_home varchar2(255)
set serverout on
begin
-- get oracle_home
sys.dbms_system.get_env('ORACLE_HOME',:xe_home);
if length(:xe_home) = 0 then
sys.dbms_output.put_line(lpad('-',80,'-'));
raise_application_error (-20001,'Oracle Home environment variable not set' );
end if;
end;
/
whenever sqlerror continue
set termout off
select :xe_home from sys.dual;
set termout on
host ^OH_HOME/perl/bin/perl -I ^OH_HOME/rdbms/admin ^OH_HOME/rdbms/admin/catcon.pl -b apx50dgrd apx50dgrd1.sql
</pre>
<ol start="5">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Start SQL*Plus and connect to </span><span style="font-family: "courier"; font-size: 10.0pt;">CDB$ROOT</span><span style="font-family: "times"; font-size: 10.0pt;"> of the database where Oracle
Application Express is installed as </span><span style="font-family: "courier"; font-size: 10.0pt;">SYS</span><span style="font-family: "times"; font-size: 10.0pt;"> specifying the </span><span style="font-family: "courier"; font-size: 10.0pt;">SYSDBA</span><span style="font-family: "times"; font-size: 10.0pt;"> role: </span></li>
</ol>
<div class="MsoNormal" style="margin-left: .5in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "times"; font-size: 10.0pt;">On Windows:</span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">SYSTEM_DRIVE:\
sqlplus /nolog </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">SQL>
CONNECT SYS as SYSDBA </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">Enter
password: SYS_password </span></div>
<div class="MsoNormal" style="margin-left: .5in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br />
<span style="font-family: "times"; font-size: 10.0pt;">On UNIX and Linux:</span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">$
sqlplus /nolog </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">SQL>
CONNECT SYS as SYSDBA </span></div>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">Enter
password: SYS_password </span></div>
<ol start="6" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">Execute the following commands: </span></li>
</ol>
<div class="MsoNormal" style="margin-left: .5in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="font-family: "courier"; font-size: 10.0pt;">@apx50dgrd.sql
</span></div>
<ol start="7" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "times"; font-size: 10.0pt;">See the next section, "</span><a href="https://docs.oracle.com/database/apex-5.1/HTMIG/cleaningup-after-failed-installation.htm#GUID-E7A956E1-00F8-44F5-B92F-6628514D2DF0"><span style="color: blue; font-family: "times"; font-size: 10.0pt;">Removing the Oracle
Application Express Release 5.1 Schema</span></a><span style="font-family: "times"; font-size: 10.0pt;">."</span></li>
</ol>
</span><br />
<ol start="5" type="1">
</ol>
Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com1tag:blogger.com,1999:blog-6139250371277978964.post-51891848206681418682016-10-28T14:25:00.001-04:002016-10-28T14:25:17.735-04:00"ORA-20001: Application ID and current security group ID are not consistent" encountered during APEX Upgrade from 4.x to 5.xRecently, our QA team at Oracle was testing database upgrades, and the following error appeared in the database upgrade log while the APEX component was being upgraded:<br />
<br />
.<span style="font-family: "Courier New",Courier,monospace;">..Installing Theme 1<br /><br />API Last Extended:20130101<br />Your Current Version:20130101<br />This import is compatible with version: 20130101<br />COMPATIBLE (You should be able to run this import without issues.)<br />--application/set_environment<br />APPLICATION 108801 - Theme: Simple Red<br />--application/delete_application<br />begin<br />*<br />ERROR at line 1:<br />ORA-20001: Application ID and current security group ID are not consistent.<br />ORA-06512: at "APEX_050000.WWV_FLOW_API", line 1419<br />ORA-06512: at "APEX_050000.WWV_FLOW_API", line 2106<br />ORA-06512: at line 2</span><br />
<br />
<span style="font-family: inherit;">A day later, our support organizat<span style="font-family: inherit;">ion reported that a customer ran <span style="font-family: inherit;">into exactly the same error when they attempted an APEX upgrade f<span style="font-family: inherit;">rom 4.2.5 to 5.0.4. I tried to reprod<span style="font-family: inherit;">uce th<span style="font-family: inherit;">e issue myself, but was unable to in a database I created us<span style="font-family: inherit;">ing DBCA. I th<span style="font-family: inherit;">en created a database in <span style="font-family: inherit;">our RDBMS development en<span style="font-family: inherit;">vironment, and was able to<span style="font-family: inherit;"> reproduce this <span style="font-family: inherit;">issue upgrading 4.<span style="font-family: inherit;">2.5 to 5.0.4.</span></span></span></span></span></span></span></span></span></span></span></span></span><br />
<br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;">I noticed in the log of my failed installation a <span style="font-family: inherit;">message</span> that errors <span style="font-family: inherit;">exist in the upgrade <span style="font-family: inherit;">progress table</span>.</span></span></span></span></span></span></span></span></span></span></span></span></span></span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> select upgrade_error from apex_050000.wwv_flow_upgrade_progress where upgrade_error is not null;<br /><br />UPGRADE_ERROR<br />--------------------------------------------------------------------------------<br />ORA-01000: maximum open cursors exceeded</span><br />
<br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;">I checked the <a href="http://docs.oracle.com/database/121/REFRN/GUID-FAFD1247-06E5-4E64-917F-AEBD4703CF40.htm#REFRN10137" target="_blank">open_cursors</a> database parameter of the <span style="font-family: inherit;">database where the upgrade failed, and found it was set to 50. <span style="font-family: inherit;">I then checked the parameter in the database <span style="font-family: inherit;">I created using DBC<span style="font-family: inherit;">A, where the APEX upgrade was suc<span style="font-family: inherit;">cessful, <span style="font-family: inherit;">and</span> noted that it was set to 300.</span></span></span></span></span></span> I r<span style="font-family: inherit;">estored the database of the failed upgrade<span style="font-family: inherit;">, and issued the follow<span style="font-family: inherit;">ing command:</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">SQL> alter system set open_cursors=300 scope=both;</span><br />
<br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;">I <span style="font-family: inherit;">re<span style="font-family: inherit;">tried the APEX upgrade to <span style="font-family: inherit;">5.0.4 and it completed successfully without errors. If you encou<span style="font-family: inherit;">nter the above error while doing an <span style="font-family: inherit;">APEX upgrade, check <span style="font-family: inherit;">the <a href="http://docs.oracle.com/database/121/REFRN/GUID-FAFD1247-06E5-4E64-917F-AEBD4703CF40.htm#REFRN10137" target="_blank">open_cursors</a> parameter, and set it to at least 300.</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-70040761011105553462015-04-17T16:26:00.000-04:002015-04-17T16:26:00.002-04:00Upgrading to Application Express 5.0 in Your Oracle Database Release 12.1 Multitenant Container Database (CDB)Woo hoo! Oracle Application Express 5.0 has been released. Read all about it <a href="http://joelkallman.blogspot.com/2015/04/oracle-application-express-5-unofficial.html" target="_blank">here</a>.<br />
<br />
The purpose of this blog post is to provide information on how to upgrade your 12.1 Multitenant Container Databases (CDBs) to APEX 5.0, and specifically ones where you have Oracle Application Express installed in CDB$ROOT (the root), and you are making use of Oracle Application Express 4.2.x in the PDBs in this CDB. There has been confusion on this topic, even from some of my colleagues at Oracle.<br />
<br />
You can <b>ignore</b> this blog post if any of the following conditions are true in your situation:<br />
<ol>
<li>You are on a release lower than 12.1</li>
<li>You are running 12.1, but it is a non container database (non-CDB)</li>
<li>You are running a 12.1 CDB, but you have de-installed Oracle Application Express from the CDB, and you are running Oracle Application Express locally in all or some of your PDBs</li>
</ol>
Since you are still reading this post, this means you have a 12.1 CDB, where Oracle Application Express is installed in the root, and you are actively using APEX in your PDBs, and you wish to upgrade the root and all of your PDBs to APEX 5.0.<br />
<br />
We have tried to make it painfully clear in <a href="https://docs.oracle.com/cd/E59726_01/install.50/e39144/pre_require.htm#HTMIG377" target="_blank">multiple</a> <a href="https://docs.oracle.com/cd/E59726_01/doc.50/e39143/toc.htm#HTMRN280" target="_blank">places</a> in the 5.0 documentation set, and on our <a href="http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-50-known-issues-2504535.html" target="_blank">known issues</a> page, that if you want to upgrade your 12.1 CDB to APEX 5.0, you must first download and install the database patch number 20618595 prior to upgrading to APEX 5.0.<br />
<br />
Below is a step by step guide based on my experience in upgrading one of our 12.1.0.2.0 development environments to Oracle Application Express 5.0.<br />
<br />
First, install the latest OPatch into your $ORACLE_HOME, by doing the following:<br />
<ol>
<li>Login to support.oracle.com</li>
<li>Click Patches & Updates tab</li>
<li>Simple search on patch number 6880880 and Platform Linux x86-64</li>
<li>Download the patched titled "Patch patch of version 12.1.0.1.7 for Oracle software releases 12.1.0.x (APR 2015)"</li>
<li>Execute the following OS commands</li>
</ol>
<span style="font-family: "Courier New",Courier,monospace;">cd $ORACLE_HOME</span><br />
<span style="font-family: "Courier New",Courier,monospace;">mv OPatch OPatch_save</span><br />
<span style="font-family: "Courier New",Courier,monospace;">unzip <path_to_zip_from_step_4>/p6880880_121010_Linux-x86-64.zip</path_to_zip_from_step_4></span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ORACLE_HOME/OPatch/opatch version</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">OPatch Version: 12.1.0.1.7<br /><br />OPatch succeeded.</span><br />
<br />
Next, you need to download and apply database patch 20618595.<br />
<ol>
<li>Login to support.oracle.com</li>
<li>Click Patches & Updates tab</li>
<li>Simple search on patch number 20618595</li>
<li>Download either the 12.1.0.1.0 or 12.1.0.2.0 patch. I was on 12.1.0.2.0 so I downloaded that version.</li>
<li>Execute the following OS commands</li>
</ol>
<span style="font-family: "Courier New",Courier,monospace;">unzip <path_to_zip_from_step_4>/p20618595_121020_Linux-x86-64.zip</path_to_zip_from_step_4></span><br />
<span style="font-family: "Courier New",Courier,monospace;">cd 20618595</span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./</span><br />
<br />
Ensure you see "Prereq "checkConflictAgainstOHWithDetail" passed." in the output. If so, proceed with shutting down all services for $ORACLE_HOME.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">lsnrctl stop</span><br />
<span style="font-family: "Courier New",Courier,monospace;">sqlplus / as sysdba</span><br />
<span style="font-family: "Courier New",Courier,monospace;">shutdown immediate</span><br />
<span style="font-family: "Courier New",Courier,monospace;">exit</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$ORACLE_HOME/OPatch/opatch apply</span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ORACLE_HOME/OPatch/opatch lsinventory</span><br />
<br />
You should now see something in your terminal similar to:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">Patch 20618595 : applied on Thu Apr 16 13:17:43 PDT 2015<br />Unique Patch ID: 18723077<br /> Created on 9 Apr 2015, 15:28:51 hrs PST8PDT<br /> Bugs fixed:<br /> 20618595</span><br />
<br />
If you do not, do not proceed. Get help from a DBA. Do not attempt to to upgrade to APEX 5.0. Do not pass Go! Do not collect $200.<br />
<br />
Now, if you did see output in your terminal similar to the above, do the following.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">lsnrctl start</span><br />
<span style="font-family: "Courier New",Courier,monospace;">sqlplus / as sysdba</span><br />
<span style="font-family: "Courier New",Courier,monospace;">startup</span><br />
<span style="font-family: "Courier New",Courier,monospace;">alter pluggable database all open;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">exit</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">cd $ORACLE_HOME/OPatch</span><br />
<span style="font-family: "Courier New",Courier,monospace;">./datapatch</span><br />
<br />
You should see output similar to:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> The following patches will be applied:<br /> 20618595 ()<br /><br />catcon: ALL catcon-related output will be written to /tmp/sqlpatch_catcon__catcon_26531.lst<br />catcon: See /tmp/sqlpatch_catcon_*.log files for output generated by scripts<br />catcon: See /tmp/sqlpatch_catcon__*.lst files for spool files, if any<br />Installing patches...<br />Patch installation complete. Total patches installed: 6<br /><br />Validating logfiles...done<br />SQL Patching tool complete on Thu Apr 16 13:49:29 2015</span><br />
<br />
Again, if you do not, and you see any type of error, get help from a DBA and do not proceed until this patch is successfully applied to the database. Once the patch is successfully applied, simply connect to CDB$ROOT as SYSDBA, and run either apexins.sql or apxrtins.sql depending on your installation type. That's it. At the end of the installation your CDB and all PDBs will be successfully upgraded to APEX 5.0. I guarantee it!<br />
<br />
<br />
<br />
Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com12tag:blogger.com,1999:blog-6139250371277978964.post-89242081512166473112013-08-15T13:54:00.000-04:002013-08-15T15:06:32.223-04:00Accepting PayPal Payments with your Oracle Cloud Database Service<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]-->If you haven't
signed up for an Oracle Database Service on the <a href="https://cloud.oracle.com/mycloud/f?p=service:home:0">Oracle Cloud</a>, you should do so
right now.<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"></span><div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">I wrote a white
paper called "<a href="http://www.oracle.com/technetwork/developer-tools/apex/application-express/integration-086636.html#PAYPAL">Integrating Application Express with PayPal PaymentsPro</a>" about six years ago and also made available a corresponding
<a href="http://www.oracle.com/technetwork/developer-tools/apex/paypal-1-130674.zip">application for download on OTN</a>. The application still works as long as you
configure it properly by supplying the right substitutions in the application
properties, most notably your PayPal API developer username, password and signature.</span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">My colleague
<a href="https://blogs.oracle.com/realworldcloudplatform/">Rick Greenwald</a> let me know about an Oracle Cloud customer that was trying to
integrate PayPal in an application in their database service. They had seen the
white paper I had written years ago but there are two requirements of the
solution described in the paper that simply won't work on the cloud:</span></div>
<ol start="1" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">You must be able to use UTL_HTTP
with a wallet</span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">You must define a PL/SQL procedure
and grant access to public on it</span></li>
</ol>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">The reason for
the public procedure is that the <a href="https://developer.paypal.com/webapps/developer/docs/classic/api/">Classic PayPal API</a> (formerly known as the NVP
API) requires a redirect URL, which Pay Pal appends a token parameter and a
PayerID parameter. The public procedure had two parameters of exactly the same
name. It occurred to me that what might work on the Oracle Cloud would be to
create a RESTful service that would accept those parameters with exactly the
same names. With help from another colleague, <a href="http://cdivilly.wordpress.com/">Colm Divilly</a>, I was able to
create such a <a href="http://www.oracle.com/technetwork/developer-tools/apex-listener/documentation/listener-dev-guide-1979546.html">RESTful resource template</a> with a get handler.</span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">It also occurred
to me that instead of using UTL_HTTP directly you could simply use the
<a href="http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_web_service.htm#BABFFDEH">APEX_WEB_SERVICE</a> API, specifically apex_web_service.make_rest_request. This
package can be freely used on the Oracle Cloud, and it supports HTTPS calls
through an instance wallet.</span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Below is a
cookbook for modifying the existing PayPal integration sample application and
using it on the Oracle Cloud. The application uses the Classic API, so look for
a white paper by Rick Greenwald on how to use the updated PayPal RESTful API
and OAuth2. (A much more modern solution.)</span></div>
<ol start="1" type="1">
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Sign up and activate a database
service on the <a href="https://cloud.oracle.com/mycloud/f?p=service:home:0">Oracle Cloud</a></span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Sign up for a <a href="https://developer.paypal.com/">PayPal developer</a>
account</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Follow the instructions to create
sandbox accounts you can use to test transactions</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Login to your database service,
click SQL Workshop, RESTful Services, and Create a new one with the
following attributes (see figure 1):</span></li>
</ol>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">a)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Name:
PayPal Accept</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">b)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">URI
Template: pay_pal?token={token}&PayerID={payerid}</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">c)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Method:
GET</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">d)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Source
Type: PL/SQL</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">e)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Source:<br />
begin<br />
<span style="mso-spacerun: yes;"> </span>paypal_accept(token => :token,<br />
<span style="mso-spacerun: yes;"> </span>PayerId => :payerid);<br />
end;</span></div>
<ol start="5" type="1">
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><a href="http://www.oracle.com/technetwork/developer-tools/apex/paypal-1-130674.zip">Download</a> and unzip the original
PayPal Integration sample application</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">On the Application Builder Home
Page, Choose Import, and use paypal_installer.sql, do not choose to
install supporting objects, you need to make changes to them and will
install them later.</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Click Edit Application, and then
Supporting Objects</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Click Prerequisites and remove check
next to Create Synonym <span style="mso-spacerun: yes;"> </span>and click
Apply Changes</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Click Installation Scripts, edit
paypal_accept.sql and replace all of its contents with code listing 1 and
click Apply Changes</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Edit paypal_api.plb and replace all
of its contents with code listing 2 and click Apply Changes</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Click Install Supporting Objects,
choose Yes and click Next and then Install</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Finally you need to change the substitution
values in the application properties, click Edit Application and then Edit
Application Properties</span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Navigate to the Substitutions
section and supply values for the following:</span></li>
</ol>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">a)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">API_USERNAME
: This is the username you find at developer.paypal.com, click Applications,
Sandbox accounts, and then Profile under the account that was initially created
when you signed up for the developer account. (It should be Type Business.
Upgrade it to Pro so that you can test the direct credit card payment feature.)
On the profile window, click API credentials tab. Your username, password, and
signature will be listed. Use this to fill out the substitutions of the same
name.</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">b)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">API_PASSWORD
: See API credentials tab</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">c)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">API_SIGNATURE
: See API credentials tab</span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">d)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">RETURN_URL
: https://database-<your_identity_domain_here>.db.us1.oraclecloudapps.com/apex/pay_pal</your_identity_domain_here></span></div>
<div class="MsoNormal" style="margin-left: 1.0in; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><span style="mso-list: Ignore;">e)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">CANCEL_URL
: https://database-<your_identity_domain_here>.db.us1.oraclecloudapps.com/apex/</your_identity_domain_here></span></div>
<ol start="14" type="1">
<li class="MsoNormal" style="mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Replace
<your_identity_domain> above with your actual identity domain and ensure
you don’t have and leading or trailing spaces in the fields, and that you
have pasted the entire API signature, it will span multiple lines. Click
Apply Changes.</your_identity_domain></span></li>
</ol>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">That’s it. The
major changes were to create a RESTful service resource template and GET
handler to handle the re-direct from PayPal, change the paypal_accept procedure
to call f directly instead of redirecting to it, and to change do_post in
paypal_api to use apex_web_service instead of UTL_HTTP directly.</span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Now you are
ready to test the application.</span></div>
<ol start="1" type="1">
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Click
Run Application</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Login
with your credentials, you may have to create an Application Express end
user account first</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">After
you are done laughing at the hugely simplistic and ugly UI (hey, it was
like 6 years ago!), choose a quantity, leave PayPal checked and click Check
Out</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">You
will be redirected to the PayPal sandbox site. You need to login using a
Personal sandbox account you should have created way back in step 3 of the
cookbook.</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">After
you log in, you will see a review screen from PayPal, click continue</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Clicking
continue should have caused you to redirect back to your RESTful services
resource template, and you will now be back in your Application Express application
on a confirm purchase page. Click Purchase.</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">You
should be on a Purchase Confirmed page now with transaction ID, order time
and amount. Click Purchase More Tickets.</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Choose
Payment Option Credit Card and Check Out</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Use
the Account type you created when creating the Sandbox personal account.
You get the account number and expire date from the Funding tab of the account
profile. Enter the expire date in the form MMYYYY no spaces, no dashes.</span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Click
Pay Now and you should be back on the Purchase Confirmed page.</span></li>
</ol>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">You are now
ready to accept payments in your database service Oracle Cloud applications.
You simply change the API_URL substitution in Application Properties to point
to the production PayPal API URL.</span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<h2 class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Figure 1</span></h2>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhOQwka34UdkDS6CLeZg4XbVlKCC82FNJt7A4TdrSSZU3TUbTpJpm6Q8vufhZK3Fd7sp6_jvtFYqqx4fdY_tSXLty1XdpgkOQPEns9L2t4dIeUTkgrI_B4n60Nx6chnEa0V9UcXGj0DgW9/s1600/paypalfig1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhOQwka34UdkDS6CLeZg4XbVlKCC82FNJt7A4TdrSSZU3TUbTpJpm6Q8vufhZK3Fd7sp6_jvtFYqqx4fdY_tSXLty1XdpgkOQPEns9L2t4dIeUTkgrI_B4n60Nx6chnEa0V9UcXGj0DgW9/s1600/paypalfig1.png" /></a></div>
<br />
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<h2 class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Code Listing 1</span></h2>
<pre class="brush:html;toolbar:true;">
create or replace procedure paypal_accept
(token in varchar2,
PayerId in varchar2)
as
begin
for c1 in (select session_id, app_id,
page_id, payer_id_item
from paypal_session_map
where session_token = token ) loop
f(p=>c1.app_id||':'||c1.page_id||':'||c1.session_id||'::::'||c1.payer_id_item||':'||PayerId);
exit;
end loop;
end paypal_accept;
/
</pre>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<h2 class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Code Listing 2</span></h2>
<pre class="brush:html;toolbar:true;">
set define off
create or replace package body paypal_api
as
function do_post(
p_api_url in varchar2,
p_api_username in varchar2,
p_api_password in varchar2,
p_signature in varchar2,
p_wallet in varchar2,
p_wallet_pwd in varchar2,
p_method in varchar2,
p_parm01 in varchar2,
p_parm02 in varchar2 default null,
p_parm03 in varchar2 default null,
p_parm04 in varchar2 default null,
p_parm05 in varchar2 default null,
p_parm06 in varchar2 default null,
p_parm07 in varchar2 default null,
p_parm08 in varchar2 default null,
p_parm09 in varchar2 default null,
p_parm10 in varchar2 default null )
return varchar2
is
l_response varchar2(4000);
l_post varchar2(4000);
begin
l_post := 'USER='||p_api_username||'&PWD='||p_api_password||'&SIGNATURE='||p_signature||
'&'||p_parm01;
if p_parm02 is not null then
l_post := l_post||'&'||p_parm02;
end if;
if p_parm03 is not null then
l_post := l_post||'&'||p_parm03;
end if;
if p_parm04 is not null then
l_post := l_post||'&'||p_parm04;
end if;
if p_parm05 is not null then
l_post := l_post||'&'||p_parm05;
end if;
if p_parm06 is not null then
l_post := l_post||'&'||p_parm06;
end if;
if p_parm07 is not null then
l_post := l_post||'&'||p_parm07;
end if;
if p_parm08 is not null then
l_post := l_post||'&'||p_parm08;
end if;
if p_parm09 is not null then
l_post := l_post||'&'||p_parm09;
end if;
if p_parm10 is not null then
l_post := l_post||'&'||p_parm10;
end if;
l_post := l_post||'&VERSION=2.6&METHOD='||p_method;
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/x-www-form-urlencoded; charset=utf-8';
l_response := apex_web_service.make_rest_request(
p_url => p_api_url,
p_http_method => 'POST',
p_body => l_post);
return wwv_flow_utilities.unescape_url(l_response);
end do_post;
function get_parameter(
p_response in varchar2,
p_parameter in varchar2 )
return varchar2
is
l_start number;
l_end number;
begin
if instr(p_response,p_parameter||'=') = 0 then
return null;
end if;
l_start := instr(p_response,p_parameter||'=') + length(p_parameter) + 1;
l_end := instr(p_response,'&',l_start);
if l_end != 0 then
return substr(p_response,l_start,l_end - l_start);
else
return substr(p_response,l_start);
end if;
end get_parameter;
procedure set_express_checkout(
p_api_url in varchar2,
p_api_username in varchar2,
p_api_password in varchar2,
p_signature in varchar2,
p_wallet in varchar2,
p_wallet_pwd in varchar2,
p_session_id in varchar2,
p_return_page in varchar2,
p_payerid_item in varchar2,
p_redirect_url in varchar2,
p_return_url in varchar2,
p_cancel_url in varchar2,
p_amount in varchar2,
p_description in varchar2,
p_token_item out varchar2 )
is
l_response varchar2(4000);
l_token varchar2(30);
begin
l_response := do_post(
p_api_url => p_api_url,
p_api_username => p_api_username,
p_api_password => p_api_password,
p_signature => p_signature,
p_wallet => p_wallet,
p_wallet_pwd => p_wallet_pwd,
p_method => 'SetExpressCheckout',
p_parm01 => 'RETURNURL='||p_return_url,
p_parm02 => 'CANCELURL='||p_cancel_url,
p_parm03 => 'AMT='||p_amount,
p_parm04 => 'DESC='||p_description );
if get_parameter(l_response,'ACK') != 'Success' then
raise_application_error(-20001,'Error: '||l_response);
end if;
l_token := replace(get_parameter(l_response,'TOKEN'),'-','%2D');
p_token_item := l_token;
delete from paypal_session_map where session_id = p_session_id;
insert into paypal_session_map values (p_session_id, apex_application.g_flow_id, p_return_page, p_payerid_item, replace(l_token,'%2D','-'));
apex_application.g_unrecoverable_error := true;
owa_util.redirect_url(p_redirect_url||l_token);
end set_express_checkout;
procedure get_express_checkout_details(
p_api_url in varchar2,
p_api_username in varchar2,
p_api_password in varchar2,
p_signature in varchar2,
p_wallet in varchar2,
p_wallet_pwd in varchar2,
p_token in varchar2,
p_email_item out varchar2,
p_fname_item out varchar2,
p_mname_item out varchar2,
p_lname_item out varchar2,
p_shiptoname_item out varchar2,
p_shiptostreet_item out varchar2,
p_shiptostreet2_item out varchar2,
p_shiptocity_item out varchar2,
p_shiptocc_item out varchar2,
p_shiptozip_item out varchar2,
p_phonenum_item out varchar2 )
is
l_response varchar2(4000);
begin
l_response := do_post(
p_api_url => p_api_url,
p_api_username => p_api_username,
p_api_password => p_api_password,
p_signature => p_signature,
p_wallet => p_wallet,
p_wallet_pwd => p_wallet_pwd,
p_method => 'GetExpressCheckoutDetails',
p_parm01 => 'TOKEN='||p_token );
if get_parameter(l_response,'ACK') != 'Success' then
raise_application_error(-20001,'Error: '||l_response);
end if;
p_email_item := get_parameter(l_response,'EMAIL');
p_fname_item := get_parameter(l_response,'FIRSTNAME');
p_mname_item := get_parameter(l_response,'MIDDLENAME');
p_lname_item := get_parameter(l_response,'LASTNAME');
p_shiptoname_item := get_parameter(l_response,'SHIPTONAME');
p_shiptostreet_item := get_parameter(l_response,'SHIPTOSTREET');
p_shiptostreet2_item := get_parameter(l_response,'SHIPTOSTREET2');
p_shiptocity_item := get_parameter(l_response,'SHIPTOCITY');
p_shiptocc_item := get_parameter(l_response,'SHIPTOCOUNTRYCODE');
p_shiptozip_item := get_parameter(l_response,'SHIPTOZIP');
p_phonenum_item := get_parameter(l_response,'PHONENUM');
end get_express_checkout_details;
procedure do_express_checkout_payment(
p_api_url in varchar2,
p_api_username in varchar2,
p_api_password in varchar2,
p_signature in varchar2,
p_wallet in varchar2,
p_wallet_pwd in varchar2,
p_session_id in varchar2,
p_token in varchar2,
p_payerid in varchar2,
p_amount in varchar2,
p_description in varchar2 )
is
l_response varchar2(4000);
begin
l_response := do_post(
p_api_url => p_api_url,
p_api_username => p_api_username,
p_api_password => p_api_password,
p_signature => p_signature,
p_wallet => p_wallet,
p_wallet_pwd => p_wallet_pwd,
p_method => 'DoExpressCheckoutPayment',
p_parm01 => 'TOKEN='||p_token,
p_parm02 => 'PAYMENTACTION=Sale',
p_parm03 => 'AMT='||p_amount,
p_parm04 => 'PAYERID='||p_payerid,
p_parm05 => 'DESC='||p_description );
if get_parameter(l_response,'ACK') != 'Success' then
raise_application_error(-20001,'Error: '||l_response);
end if;
insert into paypal_transactions values (p_session_id, p_token, get_parameter(l_response,'TRANSACTIONID'),
get_parameter(l_response,'ORDERTIME'), get_parameter(l_response,'AMT'),get_parameter(l_response,'FEEAMT'),
get_parameter(l_response,'SETTLEAMT'), get_parameter(l_response,'PAYMENTSTATUS'), get_parameter(l_response,'PENDINGREASON'),
get_parameter(l_response,'REASONCODE'));
end do_express_checkout_payment;
procedure do_direct_payment(
p_api_url in varchar2,
p_api_username in varchar2,
p_api_password in varchar2,
p_signature in varchar2,
p_wallet in varchar2,
p_wallet_pwd in varchar2,
p_session_id in varchar2,
p_ip_address in varchar2,
p_amount in varchar2,
p_creditcardtype in varchar2,
p_account in varchar2,
p_expire_date in varchar2,
p_first_name in varchar2,
p_last_name in varchar2,
p_description in varchar2,
p_tran_id_item out varchar2 )
is
l_response varchar2(4000);
l_transaction_id varchar2(30);
begin
l_response := do_post(
p_api_url => p_api_url,
p_api_username => p_api_username,
p_api_password => p_api_password,
p_signature => p_signature,
p_wallet => p_wallet,
p_wallet_pwd => p_wallet_pwd,
p_method => 'DoDirectPayment',
p_parm01 => 'PAYMENTACTION=Sale',
p_parm02 => 'IPADDRESS='||p_ip_address,
p_parm03 => 'AMT='||p_amount,
p_parm04 => 'CREDITCARDTYPE='||p_creditcardtype,
p_parm05 => 'ACCT='||p_account,
p_parm06 => 'EXPDATE='||p_expire_date,
p_parm07 => 'FIRSTNAME='||p_first_name,
p_parm08 => 'LASTNAME='||p_last_name,
p_parm09 => 'DESC='||p_description );
if get_parameter(l_response,'ACK') != 'Success' then
raise_application_error(-20001,'Error: '||l_response);
end if;
l_transaction_id := get_parameter(l_response,'TRANSACTIONID');
insert into paypal_transactions values (p_session_id, null, l_transaction_id,
null, get_parameter(l_response,'AMT'), null, null, null, null, null);
p_tran_id_item := l_transaction_id;
end do_direct_payment;
end paypal_api;
/
</pre>
<div class="MsoNormal">
<br /></div>
<!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Calibri","sans-serif";
mso-bidi-font-family:"Times New Roman";}
</style>
<![endif]-->Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com15tag:blogger.com,1999:blog-6139250371277978964.post-63163044070606528802013-07-09T16:21:00.000-04:002013-07-09T16:49:12.715-04:00Application Express in Oracle Database 12c Now on OTNSo there have been a few questions about Oracle Application Express and Oracle Database 12c, especially about the new multitenant architecture. Thanks to <a href="http://dpeake.blogspot.com/">David Peake</a>, there is now a brand new page on <a href="http://www.oracle.com/technetwork/developer-tools/apex/overview/index.html">OTN</a> providing more information, collateral, and known issues. You can find it by clicking on the big <br />
<a href="http://www.oracle.com/ocom/groups/public/@otn/documents/digitalasset/1863814.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.oracle.com/ocom/groups/public/@otn/documents/digitalasset/1863814.png" /></a> button, and then on the Application Express in Oracle Database 12c heading.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com1tag:blogger.com,1999:blog-6139250371277978964.post-87987681251618713912013-07-08T16:18:00.000-04:002013-07-08T16:22:36.142-04:00Application Express 4.2.2.00.11 for Oracle Database 12c Container DatabaseI wrote in my <a href="http://jastraub.blogspot.com/2013/06/oracle-database-12c-multitenant-option.html">previous post</a> that you cannot patch the Application Express 4.2 version in a Oracle Database 12c container database to 4.2.2.00.11, however as of a little while ago, you can now remove Application Express 4.2 from your container database and install Application Express 4.2.2.00.11 as a new install. The apex_4.2.2.zip and apex_4.2.2_en.zip files have been updated on OTN to include the appropriate _con.sql scripts used for installing into a container database.<br />
<br />
To install Application Express 4.2.2.00.11 into a container database:<br />
<br />
<ol>
<li><a href="http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html">Download or re-download</a> either apex_4.2.2.zip or apex_4.2.2_en.zip from OTN. Old distributions will not work and will not have the proper scripts.</li>
<li>Unzip apex_4.2.2[_en].zip and cd to the apex directory.</li>
<li>Connect as SYS as SYSDBA to the CDB$ROOT container of your container database.</li>
<li>Run apxremov_con.sql as described <a href="http://docs.oracle.com/cd/E16655_01/install.121/e17958/db_pluggable.htm#autoId1">here</a> the only difference is you will be using apxremov_con.sql from this distribution and not from the $ORACLE_HOME/apex directory.</li>
<li>Exit SQL*Plus, and reconnect as SYS as SYSDBA to the CDB$ROOT container.</li>
<li>Run apexins_con.sql or apxrtins_con.sql from the updated 4.2.2 distribution depending on the type of install you want, similarly described <a href="http://docs.oracle.com/cd/E16655_01/install.121/e17958/db_pluggable.htm#autoId3">here</a>.</li>
<li>If you want to configure EPG as your web listener, do the following additional steps:</li>
<li>Ensure you are still connected to the CDB$ROOT container as SYS and run apex_epg_config_con.sql passing the path to where you unzipped apex_4.2.2[_en].zip.</li>
<li>Unlock the ANONYMOUS account.</li>
<li>Change your container to the PDB that you want to be an Application Express instance and then run apxconf.sql as described <a href="http://docs.oracle.com/cd/E16655_01/install.121/e17958/db_install.htm#CIHBEIBE">here</a>. Use apxconf.sql from the 4.2.2 distribution, not the one in $ORACLE_HOME/apex.</li>
</ol>
Note that until database patch 16946990 is available you will not be able to install Application Express locally in a PDB as described <a href="http://docs.oracle.com/cd/E16655_01/install.121/e17958/db_pluggable.htm#autoId2">here</a>. The instructions above however will allow you to install Application Express 4.2.2.00.11 as a common option in the container database.<br />
<ol>
</ol>
Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-5236516208569914242013-06-26T22:25:00.000-04:002013-06-28T13:49:55.879-04:00Oracle Database 12c Multitenant Option and Application ExpressAs you probably know by now, <a href="http://www.oracle.com/technetwork/developer-tools/apex/overview/index.html">Oracle Database 12c</a> was made generally available on Tuesday, June 25th. We will be publishing a detailed page about Application Express in 12c on our <a href="http://www.oracle.com/technetwork/developer-tools/apex/overview/index.html">OTN page</a> but I wanted to make a couple of points about Application Express in the new multitenant architecture. You should also review <a href="http://docs.oracle.com/cd/E16655_01/install.121/e17958/db_pluggable.htm#CIAEGGHF">this</a> chapter if you plan on installing an Oracle Database 12c as a container database.<br />
<br />
First, if you create a container database in 12c, Application Express will be installed common in the root container. You should never connect directly to a PDB, for any reason, and run a standard Application Express install script or patch script. About the only scripts that should ever be run directly against a PDB are apxconf.sql and apxchpwd.sql, both of which pertain only to configuring a single instance of Application Express.<br />
<br />
Second, we have not released a new version of Application Express since Oracle Database 12c was released two days ago, so there is no software available to upgrade or patch the version of Application Express (4.2) that comes in the container database. The next version or patch of Application Express will contain the appropriate scripts to update a container database, so you are stuck with the version shipped with 12c until then. This seems to be contradicted by section 1.3, <br />
<div class="sect1" id="autoId2">
"Upgrading to Application Express Release 4.2.1 or Later" in the "Oracle® Application Express Installation Guide<b> </b>Release 4.2 for Oracle Database 12c.<b>" </b>It should be noted that the section currently only applies to non-container 12c databases.</div>
<br />
My comments above apply <i>only to container databases</i>. Non-container 12c databases behave just like prior versions of Oracle, and you can patch Application Express to 4.2.1, or 4.2.2 as you normally would.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-52341562149397147462013-02-03T18:10:00.000-05:002013-02-04T08:51:22.385-05:00Scheduling an Excel Format Report with Application Express<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
<w:UseFELayout/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
mso-pagination:widow-orphan;
font-size:11.0pt;
mso-bidi-font-size:10.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style>
<![endif]-->
<br />
<div class="MsoNormal">
Recently I assisted a colleague (with much help from <a href="http://marcsewtz.blogspot.com/">Marc Sewtz</a>) that wanted to send an
Excel document attached to an email showing new customers on a scheduled basis.
Seemed like a reasonable request since APEX_MAIL has had attachment support
since 4.1 (thanks to <a href="http://joelkallman.blogspot.com/">Joel</a>) and <a href="http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_util.htm#autoId51">APEX_UTIL.GET_PRINT_DOCUMENT</a>
can get a BiPublisher report as a BLOB. In assisting my co-worker I learned at
least three nuggets about accomplishing this feat.</div>
<ol>
<li>You
cannot use GET_PRINT_DOCUMENT Signature 2 or 3 which accept the name of the
report defined already in an application in a scheduler job. You must use
either Signature 1 or 4 that allows you to pass in both the report data and the
report layout. </li>
<li><a href="http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_xmlgen.htm#i1012053">DBMS_XMLGEN</a>
which allows you to generate XML based on query escapes special characters using
& notation. The BiPublisher convert servlet will choke if it receives
data that contains an &. You must do your own escaping in the query itself
to make sure DBMS_XMLGEN won’t produce a document with an ampersand in it.</li>
<li>In
order to get an Excel document using GET_PRINT_DOCUMENT Signature 4, you must
use ‘Excel’ for the p_document_format parameter, not ‘xls’ as the documentation
suggests.</li>
</ol>
<div class="MsoNormal">
Armed with these three nuggets, let’s use the Sample
Database Application to schedule an Excel document based on the orders table to
be emailed to us.</div>
<div class="MsoNormal">
Since I have BiPublisher available to me I am going to use
the <a href="http://www.oracle.com/technetwork/middleware/bi-publisher/downloads/index.html">BiPublisher
Word plugin</a> to create a rtf template for my report layout. I find it much
easier to use than trying to create an xsl-fo template. To use this plugin, I get
the XML data for my query by creating a Report Query in shared components and
then click the Download button.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.blogger.com/blogger.g?blogID=6139250371277978964" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="http://www.blogger.com/blogger.g?blogID=6139250371277978964" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjGc3t9JWfT-5aGgIIyAzkkXjiTt5gT4qQzZ2vMwV2iHf9Xp9wjCErKt8vuZ2p0aGlP4aSphNBe3RcV5Qlg7pu8sRbIhXZTUVU0HZndi_KsLGEy6cbiAaZao5_8JlLS2vO82DQy5spRKvS/s1600/downloadxml.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjGc3t9JWfT-5aGgIIyAzkkXjiTt5gT4qQzZ2vMwV2iHf9Xp9wjCErKt8vuZ2p0aGlP4aSphNBe3RcV5Qlg7pu8sRbIhXZTUVU0HZndi_KsLGEy6cbiAaZao5_8JlLS2vO82DQy5spRKvS/s1600/downloadxml.png" /></a></div>
<br />
<br />
<a href="http://www.blogger.com/blogger.g?blogID=6139250371277978964" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a>Now I load the data into the BiPublisher Word plugin and run
the table wizard to create a simple table. The result looks like the following
picture.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAJ11BMztHW1C1tdlC1hOZoXjXNzrVCMj1rgGieHOzfUdwwlXbZjEcJmL7CgB-SE1ytdNl8O8mhZ55lwRNORBvojyPaDchGjvRozJZR4XvGRP_FdpVtsQzWsnKe4Fcg1yNGE6Eap7M8m-H/s1600/rtftemplate.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="211" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAJ11BMztHW1C1tdlC1hOZoXjXNzrVCMj1rgGieHOzfUdwwlXbZjEcJmL7CgB-SE1ytdNl8O8mhZ55lwRNORBvojyPaDchGjvRozJZR4XvGRP_FdpVtsQzWsnKe4Fcg1yNGE6Eap7M8m-H/s640/rtftemplate.png" width="640" /></a></div>
</div>
<div class="MsoNormal">
<br />
I save the document in rtf format, and then open the
document using a text editor. I build a local string up in my procedure
SEND_ORDERS described and listed next.</div>
<div class="MsoNormal">
SEND_ORDERS uses DBMS_XMLGEN to create the XML data that is
passed into GET_PRINT_DOCUMENT. The report layout that is passed in is built up
in the procedure using the text that makes up the rtf document. Once I get the
blob back from GET_PRINT_DOCUMENT, I simply attach it to an email using
APEX_MAIL.</div>
<pre class="sql" name="code">
create or replace procedure "SEND_ORDERS"
is
l_id number;
l_document BLOB;
l_docName varchar2(200);
l_ctx_hdl dbms_xmlgen.ctxHandle;
l_body_html varchar2(4000);
l_subject varchar(200);
l_workspace_id number;
l_xml_data clob;
l_report_layout clob;
BEGIN
l_workspace_id := apex_util.find_security_group_id (p_workspace => 'JASON');
apex_util.set_security_group_id (p_security_group_id => l_workspace_id);
-- generate XML data
l_ctx_hdl := dbms_xmlgen.newcontext('
select
lpad(to_char(o.order_id),4,''0000'') order_number,
o.order_id,
trunc(o.order_timestamp) order_date,
replace(replace(o.user_name,''&'',''%26amp;''),chr(39),''%26apos;'') sales_rep,
o.order_total,
c.cust_last_name || '', '' || c.cust_first_name customer_name
from
demo_orders o,
demo_customers c
where
o.customer_id = c.customer_id
');
dbms_xmlgen.setnullhandling(l_ctx_hdl,2);
l_xml_data := dbms_xmlgen.getxml(l_ctx_hdl);
--get report layout
l_report_layout := '{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;}
{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;}
{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}
{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f39\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f40\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}
{\f42\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f44\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}
{\f46\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f409\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\f410\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}
{\f412\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\f413\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\f416\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\f417\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}
{\flomajor\f31508\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}
{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}
{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbmajor\f31518\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}
{\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbmajor\f31521\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}
{\fdbmajor\f31523\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}
{\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhimajor\f31528\fbidi \froman\fcharset238\fprq2 Cambria CE;}{\fhimajor\f31529\fbidi \froman\fcharset204\fprq2 Cambria Cyr;}
{\fhimajor\f31531\fbidi \froman\fcharset161\fprq2 Cambria Greek;}{\fhimajor\f31532\fbidi \froman\fcharset162\fprq2 Cambria Tur;}{\fhimajor\f31535\fbidi \froman\fcharset186\fprq2 Cambria Baltic;}
{\fhimajor\f31536\fbidi \froman\fcharset163\fprq2 Cambria (Vietnamese);}{\fbimajor\f31538\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbimajor\f31539\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}
{\fbimajor\f31541\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbimajor\f31542\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}
{\fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbimajor\f31546\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}
{\flominor\f31548\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flominor\f31549\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flominor\f31551\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}
{\flominor\f31552\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}
{\flominor\f31555\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flominor\f31556\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbminor\f31558\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}
{\fdbminor\f31559\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbminor\f31561\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbminor\f31562\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}
{\fdbminor\f31563\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbminor\f31564\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbminor\f31565\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}
{\fdbminor\f31566\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhiminor\f31568\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\fhiminor\f31569\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}
{\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}
{\fhiminor\f31576\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}{\fbiminor\f31578\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbiminor\f31579\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}
{\fbiminor\f31581\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbiminor\f31582\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbiminor\f31583\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}
{\fbiminor\f31584\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbiminor\f31585\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbiminor\f31586\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}
{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;
\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red231\green243\blue253;}{\*\defchp \f31506\fs22 }{\*\defpap \ql \li0\ri0\sa200\sl276\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025
\ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 \sqformat \spriority0 \styrsid12868897 Normal;}{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\*
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa200\sl276\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext11 \ssemihidden \sunhideused \sqformat Normal Table;}{\*
\ts15\tsrowd\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10
';
l_report_layout := l_report_layout||'\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon11 \snext15 \spriority59 \styrsid15754494
Table Grid;}}{\*\rsidtbl \rsid12868897\rsid15754494}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author jstraub}{\operator jstraub}
{\creatim\yr2013\mo2\dy3\hr16\min22}{\revtim\yr2013\mo2\dy3\hr16\min23}{\version1}{\edmins1}{\nofpages1}{\nofwords39}{\nofchars226}{\*\company Oracle Corporation}{\nofcharsws264}{\vern32773}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2
003/wordml}}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect
';
l_report_layout := l_report_layout||'\widowctrl\ftnbj\aenddoc\trackmoves1\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors1\noxlattoyen
\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1
\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
\asianbrkrule\rsidroot15754494\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0
{\*\wgrffmtfilter 2450}\nofeaturethrottle1\ilfomacatclnup0{\*\docvar {xdo0001}{PD9mb3ItZWFjaDpST1c/Pg==}}{\*\docvar {xdo0002}{PD9PUkRFUl9OVU1CRVI/Pg==}}{\*\docvar {xdo0003}{PD9PUkRFUl9JRD8+}}{\*\docvar {xdo0004}{PD9PUkRFUl9EQVRFPz4=}}
{\*\docvar {xdo0005}{PD9TQUxFU19SRVA/Pg==}}{\*\docvar {xdo0006}{PD9PUkRFUl9UT1RBTD8+}}{\*\docvar {xdo0007}{PD9DVVNUT01FUl9OQU1FPz4=}}{\*\docvar {xdo0008}{PD9lbmQgZm9yLWVhY2g/Pg==}}\ltrpar \sectd \ltrsect
\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}
{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang
{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494
\par \ltrrow}\trowd \irow0\irowband0\ltrrow\ts15\trgaph108\trleft-108\trhdr\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10
\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid15754494\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10
\clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx1663\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17
\cellx3051\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx4571\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb
\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx5983\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx7550\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx9468
\pard\plain \ltrpar\ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\yts15 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31507
\ltrch\fcs0 \b\insrsid15754494 Order Number}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 \cell }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\insrsid15754494 Order Id}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494
\cell }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\insrsid15754494 Order Date}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 \cell }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\insrsid15754494 Sales Rep}{\rtlch\fcs1 \af31507 \ltrch\fcs0
\insrsid15754494\charrsid15754494 \cell }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\insrsid15754494 Order Total}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 \cell }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\insrsid15754494 Customer Name}{
\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 \cell }\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494 \trowd \irow0\irowband0\ltrrow\ts15\trgaph108\trleft-108\trhdr\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr
\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 \trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid15754494\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt\clbrdrt
\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx1663\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx3051\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx4571\clvertalt
\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx5983\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr
\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx7550\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth1596\clcbpatraw17 \cellx9468
\row \ltrrow}\trowd \irow1\irowband1\lastrow \ltrrow\ts15\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10
\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid15754494\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10
\clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx1663\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx3051\clvertalt
\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx4571\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx5983\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx7550\clvertalt\clbrdrt\brdrs\brdrw10
\clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx9468\pard\plain \ltrpar\ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid15754494\yts15
\rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \cf9\insrsid15754494\charrsid15754494 {\*\bkmkstart Text1} FORMTEXT }{
\rtlch\fcs1 \af31507 \ltrch\fcs0 \cf9\insrsid15754494\charrsid15754494 {\*\datafield 80010000000000000554657874310002462000000000000f3c3f7265663a78646f303030313f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text1}
{\*\ffdeftext F }{\*\ffstattext }}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \cf9\lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 F }}}\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj
{\*\bkmkend Text1}{\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\bkmkstart Text2} FORMTEXT }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\datafield
8001000000000000055465787432000c4f524445525f4e554d42455200000000000f3c3f7265663a78646f303030323f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text2}{\*\ffdeftext ORDER_NUMBER}{\*\ffstattext }}}}}{\fldrslt {
\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 ORDER_NUMBER}}}\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494
{\*\bkmkend Text2}\cell }\pard \ltrpar\ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\yts15 {\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\bkmkstart Text3} FORMTEXT
}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\datafield 800100000000000005546578743300084f524445525f494400000000000f3c3f7265663a78646f303030333f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text3}
{\*\ffdeftext ORDER_ID}{\*\ffstattext }}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 ORDER_ID}}}\sectd \ltrsect
\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494 {\*\bkmkend Text3}\cell }{\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494
{\*\bkmkstart Text4} FORMTEXT }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\datafield 8001000000000000055465787434000a4f524445525f4441544500000000000f3c3f7265663a78646f303030343f3e0000000000}
{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text4}{\*\ffdeftext ORDER_DATE}{\*\ffstattext }}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 ORDER_DATE}}}
\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494 {\*\bkmkend Text4}\cell }{\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0
\insrsid15754494\charrsid15754494 {\*\bkmkstart Text5} FORMTEXT }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\datafield 8001000000000000055465787435000953414c45535f52455000000000000f3c3f7265663a78646f303030353f3e0000000000}
{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text5}{\*\ffdeftext SALES_REP}{\*\ffstattext }}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 SALES_REP}}}
\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494 {\*\bkmkend Text5}\cell }{\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0
\insrsid15754494\charrsid15754494 {\*\bkmkstart Text6} FORMTEXT }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\datafield 8001000000000000055465787436000b4f524445525f544f54414c00000000000f3c3f7265663a78646f303030363f3e0000000000}
{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text6}{\*\ffdeftext ORDER_TOTAL}{\*\ffstattext }}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 ORDER_TOTAL}}}
\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494 {\*\bkmkend Text6}\cell }\pard \ltrpar
\ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid15754494\yts15 {\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\bkmkstart Text7} FORMTEXT }{\rtlch\fcs1
\af31507 \ltrch\fcs0 \insrsid15754494\charrsid15754494 {\*\datafield 8001000000000000055465787437000d435553544f4d45525f4e414d4500000000000f3c3f7265663a78646f303030373f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text7}
{\*\ffdeftext CUSTOMER_NAME}{\*\ffstattext }}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 CUSTOMER_NAME}}}\sectd \ltrsect
\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\*\bkmkend Text7}{\field\flddirty{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \cf9\insrsid15754494\charrsid15754494 {\*\bkmkstart Text8} FORMTEXT }{\rtlch\fcs1 \af31507 \ltrch\fcs0
\cf9\insrsid15754494\charrsid15754494 {\*\datafield 80010000000000000554657874380002204500000000000f3c3f7265663a78646f303030383f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text8}{\*\ffdeftext E}{\*\ffstattext
}}}}}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \cf9\lang1024\langfe1024\noproof\insrsid15754494\charrsid15754494 E}}}\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid12868897\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0
\insrsid15754494 {\*\bkmkend Text8}\cell }\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494 \trowd \irow1\irowband1\lastrow \ltrrow\ts15\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10
\trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 \trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid15754494\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt
\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx1663\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx3051\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx4571\clvertalt\clbrdrt\brdrs\brdrw10
\clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx5983\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx7550\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth1596\clshdrawnil \cellx9468\row }\pard \ltrpar
\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15754494
';
l_report_layout := l_report_layout||'\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid12868897
\par }{\*\themedata 504b030414000600080000002100828abc13fa0000001c020000130000005b436f6e74656e745f54797065735d2e786d6cac91cb6ac3301045f785fe83d0b6d8
72ba28a5d8cea249777d2cd20f18e4b12d6a8f843409c9df77ecb850ba082d74231062ce997b55ae8fe3a00e1893f354e9555e6885647de3a8abf4fbee29bbd7
2a3150038327acf409935ed7d757e5ee14302999a654e99e393c18936c8f23a4dc072479697d1c81e51a3b13c07e4087e6b628ee8cf5c4489cf1c4d075f92a0b
44d7a07a83c82f308ac7b0a0f0fbf90c2480980b58abc733615aa2d210c2e02cb04430076a7ee833dfb6ce62e3ed7e14693e8317d8cd0433bf5c60f53fea2fe7
065bd80facb647e9e25c7fc421fd2ddb526b2e9373fed4bb902e182e97b7b461e6bfad3f010000ffff0300504b030414000600080000002100a5d6a7e7c00000
00360100000b0000005f72656c732f2e72656c73848fcf6ac3300c87ef85bd83d17d51d2c31825762fa590432fa37d00e1287f68221bdb1bebdb4fc7060abb08
84a4eff7a93dfeae8bf9e194e720169aaa06c3e2433fcb68e1763dbf7f82c985a4a725085b787086a37bdbb55fbc50d1a33ccd311ba548b63095120f88d94fbc
52ae4264d1c910d24a45db3462247fa791715fd71f989e19e0364cd3f51652d73760ae8fa8c9ffb3c330cc9e4fc17faf2ce545046e37944c69e462a1a82fe353
bd90a865aad41ed0b5b8f9d6fd010000ffff0300504b0304140006000800000021006b799616830000008a0000001c0000007468656d652f7468656d652f7468
656d654d616e616765722e786d6c0ccc4d0ac3201040e17da17790d93763bb284562b2cbaebbf600439c1a41c7a0d29fdbd7e5e38337cedf14d59b4b0d592c9c
070d8a65cd2e88b7f07c2ca71ba8da481cc52c6ce1c715e6e97818c9b48d13df49c873517d23d59085adb5dd20d6b52bd521ef2cdd5eb9246a3d8b4757e8d3f7
29e245eb2b260a0238fd010000ffff0300504b03041400060008000000210096b5ade296060000501b0000160000007468656d652f7468656d652f7468656d65
312e786d6cec594f6fdb3614bf0fd87720746f6327761a07758ad8b19b2d4d1bc46e871e698996d850a240d2497d1bdae38001c3ba618715d86d87615b8116d8
a5fb34d93a6c1dd0afb0475292c5585e9236d88aad3e2412f9e3fbff1e1fa9abd7eec70c1d1221294fda5efd72cd4324f1794093b0eddd1ef62fad79482a9c04
98f184b4bd2991deb58df7dfbb8ad755446282607d22d771db8b944ad79796a40fc3585ee62949606ecc458c15bc8a702910f808e8c66c69b9565b5d8a314d3c
94e018c8de1a8fa94fd05093f43672e23d06af89927ac06762a049136785c10607758d9053d965021d62d6f6804fc08f86e4bef210c352c144dbab999fb7b471
7509af678b985ab0b6b4ae6f7ed9ba6c4170b06c788a705430adf71bad2b5b057d03606a1ed7ebf5babd7a41cf00b0ef83a6569632cd467faddec9699640f671
9e76b7d6ac355c7c89feca9cccad4ea7d36c65b258a206641f1b73f8b5da6a6373d9c11b90c537e7f08dce66b7bbeae00dc8e257e7f0fd2badd5868b37a088d1
e4600ead1ddaef67d40bc898b3ed4af81ac0d76a197c86826828a24bb318f3442d8ab518dfe3a20f000d6458d104a9694ac6d88728eee2782428d60cf03ac1a5
193be4cbb921cd0b495fd054b5bd0f530c1931a3f7eaf9f7af9e3f45c70f9e1d3ff8e9f8e1c3e3073f5a42ceaa6d9c84e5552fbffdeccfc71fa33f9e7ef3f2d1
17d57859c6fffac327bffcfc793510d26726ce8b2f9ffcf6ecc98baf3efdfdbb4715f04d814765f890c644a29be408edf3181433567125272371be15c308d3f2
8acd249438c19a4b05fd9e8a1cf4cd296699771c393ac4b5e01d01e5a30a787d72cf1178108989a2159c77a2d801ee72ce3a5c545a6147f32a99793849c26ae6
6252c6ed637c58c5bb8b13c7bfbd490a75330f4b47f16e441c31f7184e140e494214d273fc80900aedee52ead87597fa824b3e56e82e451d4c2b4d32a423279a
668bb6690c7e9956e90cfe766cb37b077538abd27a8b1cba48c80acc2a841f12e698f13a9e281c57911ce298950d7e03aba84ac8c154f8655c4f2af074481847
bd804859b5e696007d4b4edfc150b12addbecba6b18b148a1e54d1bc81392f23b7f84137c2715a851dd0242a633f900710a218ed715505dfe56e86e877f0034e
16bafb0e258ebb4faf06b769e888340b103d3311da9750aa9d0a1cd3e4efca31a3508f6d0c5c5c398602f8e2ebc71591f5b616e24dd893aa3261fb44f95d843b
5974bb5c04f4edafb95b7892ec1108f3f98de75dc97d5772bdff7cc95d94cf672db4b3da0a6557f70db629362d72bcb0431e53c6066acac80d699a6409fb44d0
8741bdce9c0e4971624a2378cceaba830b05366b90e0ea23aaa241845368b0eb9e2612ca8c742851ca251ceccc70256d8d87265dd96361531f186c3d9058edf2
c00eafe8e1fc5c509031bb4d680e9f39a3154de0accc56ae644441edd76156d7429d995bdd88664a9dc3ad50197c38af1a0c16d684060441db02565e85f3b966
0d0713cc48a0ed6ef7dedc2dc60b17e92219e180643ed27acffba86e9c94c78ab90980d8a9f0913ee49d62b512b79626fb06dccee2a432bbc60276b9f7dec44b
7904cfbca4f3f6443ab2a49c9c2c41476dafd55c6e7ac8c769db1bc399161ee314bc2e75cf8759081743be1236ec4f4d6693e5336fb672c5dc24a8c33585b5fb
9cc24e1d4885545b58463634cc5416022cd19cacfccb4d30eb45296023fd35a458598360f8d7a4003bbaae25e331f155d9d9a5116d3bfb9a95523e51440ca2e0
088dd844ec6370bf0e55d027a012ae264c45d02f708fa6ad6da6dce29c255df9f6cae0ec38666984b372ab5334cf640b37795cc860de4ae2816e95b21be5ceaf
8a49f90b52a51cc6ff3355f47e0237052b81f6800fd7b802239daf6d8f0b1571a8426944fdbe80c6c1d40e8816b88b8569082ab84c36ff0539d4ff6dce591a26
ade1c0a7f669880485fd484582903d284b26fa4e2156cff62e4b9265844c4495c495a9157b440e091bea1ab8aaf7760f4510eaa69a6465c0e04ec69ffb9e65d0
28d44d4e39df9c1a52ecbd3607fee9cec7263328e5d661d3d0e4f62f44acd855ed7ab33cdf7bcb8ae889599bd5c8b3029895b6825696f6af29c239b75a5bb1e6
345e6ee6c28117e73586c1a2214ae1be07e93fb0ff51e133fb65426fa843be0fb515c187064d0cc206a2fa926d3c902e907670048d931db4c1a44959d366ad93
b65abe595f70a75bf03d616c2dd959fc7d4e6317cd99cbcec9c58b34766661c7d6766ca1a9c1b327531486c6f941c638c67cd22a7f75e2a37be0e82db8df9f30
254d30c1372581a1f51c983c80e4b71ccdd28dbf000000ffff0300504b0304140006000800000021000dd1909fb60000001b010000270000007468656d652f74
68656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73848f4d0ac2301484f78277086f6fd3ba109126dd88d0add40384e4350d363f24
51eced0dae2c082e8761be9969bb979dc9136332de3168aa1a083ae995719ac16db8ec8e4052164e89d93b64b060828e6f37ed1567914b284d262452282e3198
720e274a939cd08a54f980ae38a38f56e422a3a641c8bbd048f7757da0f19b017cc524bd62107bd5001996509affb3fd381a89672f1f165dfe514173d9850528
a2c6cce0239baa4c04ca5bbabac4df000000ffff0300504b01022d0014000600080000002100828abc13fa0000001c0200001300000000000000000000000000
000000005b436f6e74656e745f54797065735d2e786d6c504b01022d0014000600080000002100a5d6a7e7c0000000360100000b000000000000000000000000
002b0100005f72656c732f2e72656c73504b01022d00140006000800000021006b799616830000008a0000001c00000000000000000000000000140200007468
656d652f7468656d652f7468656d654d616e616765722e786d6c504b01022d001400060008000000210096b5ade296060000501b000016000000000000000000
00000000d10200007468656d652f7468656d652f7468656d65312e786d6c504b01022d00140006000800000021000dd1909fb60000001b010000270000000000
00000000000000009b0900007468656d652f7468656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73504b050600000000050005005d010000960a00000000}
{\*\colorschememapping 3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d3822207374616e64616c6f6e653d22796573223f3e0d0a3c613a636c724d
617020786d6c6e733a613d22687474703a2f2f736368656d61732e6f70656e786d6c666f726d6174732e6f72672f64726177696e676d6c2f323030362f6d6169
6e22206267313d226c743122207478313d22646b3122206267323d226c743222207478323d22646b322220616363656e74313d22616363656e74312220616363
656e74323d22616363656e74322220616363656e74333d22616363656e74332220616363656e74343d22616363656e74342220616363656e74353d22616363656e74352220616363656e74363d22616363656e74362220686c696e6b3d22686c696e6b2220666f6c486c696e6b3d22666f6c486c696e6b222f3e}
{\*\latentstyles\lsdstimax267\lsdlockeddef0\lsdsemihiddendef1\lsdunhideuseddef1\lsdqformatdef0\lsdprioritydef99{\lsdlockedexcept \lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority0 \lsdlocked0 Normal;
\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority9 \lsdlocked0 heading 1;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 2;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 3;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 4;
\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 5;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 6;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 7;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 8;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 9;
\lsdpriority39 \lsdlocked0 toc 1;\lsdpriority39 \lsdlocked0 toc 2;\lsdpriority39 \lsdlocked0 toc 3;\lsdpriority39 \lsdlocked0 toc 4;\lsdpriority39 \lsdlocked0 toc 5;\lsdpriority39 \lsdlocked0 toc 6;\lsdpriority39 \lsdlocked0 toc 7;
\lsdpriority39 \lsdlocked0 toc 8;\lsdpriority39 \lsdlocked0 toc 9;\lsdqformat1 \lsdpriority35 \lsdlocked0 caption;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority10 \lsdlocked0 Title;\lsdpriority1 \lsdlocked0 Default Paragraph Font;
\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority11 \lsdlocked0 Subtitle;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority22 \lsdlocked0 Strong;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority20 \lsdlocked0 Emphasis;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority59 \lsdlocked0 Table Grid;\lsdunhideused0 \lsdlocked0 Placeholder Text;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority1 \lsdlocked0 No Spacing;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 1;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 1;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 1;\lsdunhideused0 \lsdlocked0 Revision;
\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority34 \lsdlocked0 List Paragraph;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority29 \lsdlocked0 Quote;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority30 \lsdlocked0 Intense Quote;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 1;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 1;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 2;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 2;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 2;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 2;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 2;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 3;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 3;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 3;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 3;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 3;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 4;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 4;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 4;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 4;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 5;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 5;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 5;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 5;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 5;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 6;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 6;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 6;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 6;
\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 6;
\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority19 \lsdlocked0 Subtle Emphasis;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority21 \lsdlocked0 Intense Emphasis;
\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority31 \lsdlocked0 Subtle Reference;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority32 \lsdlocked0 Intense Reference;
\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority33 \lsdlocked0 Book Title;\lsdpriority37 \lsdlocked0 Bibliography;\lsdqformat1 \lsdpriority39 \lsdlocked0 TOC Heading;}}{\*\datastore 010500000200000018000000
';
l_report_layout := l_report_layout||'4d73786d6c322e534158584d4c5265616465722e352e3000000000000000000000060000
d0cf11e0a1b11ae1000000000000000000000000000000003e000300feff090006000000000000000000000001000000010000000000000000100000feffffff00000000feffffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
fffffffffffffffffdfffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffff52006f006f007400200045006e00740072007900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000500ffffffffffffffffffffffffec69d9888b8b3d4c859eaf6cd158be0f000000000000000000000000601c
50ad5402ce01feffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000105000000000000}}';
--EMAIL BODY
l_body_html := 'Attached is the latest report of orders.';
--EMAIL SUBJECT
l_subject := 'Orders';
l_document := APEX_UTIL.GET_PRINT_DOCUMENT(
p_report_data=>l_xml_data,
p_report_layout=>l_report_layout,
p_report_layout_type=>'rtf',
p_document_format=>'Excel');
--EMAIL CONTENTS
l_id := APEX_MAIL.SEND
(
P_TO => 'jason@example.com',
P_FROM => 'do-not-reply@example.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => l_subject
);
--SEND EMAIL W/ ATTACHMENT
l_docName := 'Orders ' || to_char(systimestamp,'mm-dd-yy hh24') || '.xls';
APEX_MAIL.ADD_ATTACHMENT
(
p_mail_id => l_id,
p_attachment => l_document,
p_filename => l_docName,
p_mime_type => 'application/vnd.ms-excel'
);
END;
</pre>
<div class="MsoNormal">
<br />
<br />
<br />
I test the procedure from SQL Commands and then create the
scheduler job using <a href="http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_sched.htm#CIHHBGGI">DBMS_SCHEDULER</a>.<br />
</div>
<pre class="sql" name="code">
begin
sys.dbms_scheduler.create_job (
job_name => 'JOB_SEND_ORDERS',
job_type => 'STORED_PROCEDURE',
job_action => 'SEND_ORDERS',
start_date => systimestamp,
repeat_interval => 'freq=hourly',
end_date => NULL,
enabled => TRUE,
comments => 'Send orders hourly' );
end;
</pre>
<div class="MsoNormal">
And finally, I test the scheduler job using
DBMS_SCHEDULER.RUN_JOB.</div>
<div class="MsoNormal">
<br />
Now of course you can adapt this example to use Apache FOP
and an xsl-fo style template if you don’t have access to BiPublisher, but that
is an exercise left to the reader.</div>
Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com2tag:blogger.com,1999:blog-6139250371277978964.post-12298068511347588442012-10-16T09:08:00.000-04:002012-10-16T09:08:29.795-04:00APEX_WEB_SERVICE API + Oracle Social NetworkDimitri Gielis has written an excellent <a href="http://dgielis.blogspot.be/2012/10/integration-of-oracle-social-network.html">blog post</a> on integrating <a href="http://www.oracle.com/technetwork/developer-tools/apex/overview/index.html">Oracle Application Express</a> with the <a href="http://www.oracle.com/technetwork/middleware/webcenter/socialnetwork/overview/index.html">Oracle Social Network</a> using the <a href="http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_web_service.htm#BABFFDEH">APEX_WEB_SERVICE</a> API. He has even shared the code on a project on <a href="https://github.com/dgielis/apex-osn">GitHub</a>. If you ever have a need to integrate Application Express with a RESTful web service, I recommend you check out Dimitri's work for a good example.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-71039246070959106432011-10-21T13:50:00.001-04:002011-10-21T13:58:31.785-04:00Three New Web Service Demos Available on the OLL<span xmlns=''><p>One of my colleagues at Oracle, <a href='http://marcieyoung.blogspot.com/'>Marcie Young</a>, has created three new <a href='https://apex.oracle.com/pls/apex/f?p=44785:24:0::NO::P24_CONTENT_ID,P24_PREV_PAGE:5818,1'>excellent demonstrations</a> of consuming web services in Application Express 4.1.<br /></p><p>The first demonstration called "Creating and Using a Manual SOAP Web Service in Your Application" takes you step by step through creating a manual web service reference, and then using the Create Form and Report on Web Service wizard to create the page to interact with the service. The ability to use that wizard on a manual web reference was a new feature on 4.0. (This demonstration even exposed a slight branching inconvenience that I am going to file and fix in 4.1.1.)<br /></p><p>"Creating and Using a RESTful Web Service with an XML Response" uses the Google Geocoder v3 web service and is a classic example of consuming a RESTful style web service in Application Express.<br /></p><p>Finally, "Creating and Using a RESTful Web Service with an XML Response and a Bind Variable" is a great example of consuming a RESTful service where the parameter is passed as part of the URI path (not part of the query string), like http://someservice.com/employees/{id}, where {id} is the employee that you want to retrieve. This can be accomplished by using &ITEM_NAME. syntax when you specify the URL endpoint in the RESTful web service reference.<br /></p><p>All of these demonstrations reinforce your need to learn to write XPath expressions to traverse an XML document. If you don't know what I am talking about, there is an excellent <a href='http://www.w3schools.com/xpath/default.asp'>XPath tutorial</a> at <a href='http://www.w3schools.com'>www.w3schools.com</a>. <br /></p><p>So check these demonstrations out (they are nice videos) and give your mad props to Marcie!</p></span>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-30662016025153054212011-01-03T10:02:00.001-05:002018-11-14T14:52:24.445-05:00Building an Amazon S3 Client with Application Express 4.0 White Paper Available<div><font xmlns=""><br /><p>If you have seen me present about web services and Oracle Application Express 4.0 in the last year (at APEXposed, OOW, or ODTUG Kaleidoscope), you have probably heard me say that a white paper about building an Amazon S3 client with APEX was forthcoming. I am happy to announce the paper is <a href="https://www.oracle.com/technetwork/developer-tools/apex/learnmore/integration-086636.html">now available</a> along with a corresponding sample application. The best part is with the <a href="http://aws.amazon.com/free/">AWS Free Usage Tier</a>, you can try everything out for free!</p></font></div>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com15tag:blogger.com,1999:blog-6139250371277978964.post-11188515550190400202010-09-14T12:47:00.001-04:002010-09-14T14:48:08.187-04:00Adding a Context Menu to a Tree Region<div><div><div><span xmlns=""><p>One of the nice new features of Application Express is the new tree region. It is based on <a href="http://www.jstree.com/">jsTree</a> and supports features such as tool-tips. jsTree is the same tree used for the new tree view of the Application Builder Page Definition page. That page supports a right click context menu which is missing from the current version of the Application Express new tree region. With a little help from <a href="http://www.inside-oracle-apex.com/">Patrick</a>, I was able to add a context menu to a tree region I was working on for an update to the Document Library packaged application. The purpose of this article is to describe how to do this for your tree regions. I will use the EMP table as a simple example. </p><br /><p><strong>Disclaimer:</strong><br /><em>Patrick wanted me to mention that we may change the implementation of the tree in the future, so you may have to adjust the JavaScript code listed here in future versions of Application Express.<br /></em></p><br /><br /><p>Let's start by creating a copy of the emp table, emp2, so you don't actually mess with the emp data. Use the SQL Workshop SQL Command Processor and the code in listing 1 to create emp2.<br /></p><br /><br /><h3>Code Listing 1<br /></h3><br /><pre class="sql" name="code"><br />create table emp2 as select * from emp<br />/<br /><br />alter table emp2 add constraint emp2_pk primary key (empno)<br />/<br /><br />alter table emp2 add constraint emp2_fk foreign key (mgr) references emp2(empno)<br />/<br /></pre><br /><br /><br /><p><br /></p><br /><br /><h2>Create Application and Tree<br /></h2><br /><p>With emp2 in place you are ready to create an application. Simply run the create application wizard and create a form and report on emp2. You will replace the report on page 1 with a tree region. After the application is created, edit page 1. Delete the report region and then create a new tree region specifying the following options:<br /></p><br /><ol><br /><li>Display Attributes, Title: <strong>Employees</strong><br /></li><br /><li>Tree Template: <strong>Default</strong><br /></li><br /><li>Table/View: <strong>EMP2</strong><br /></li><br /><li>Confirm that all values are defaulted on the Query step<br /></li><br /><li>Tooltip: <strong>Database Column</strong><br /></li><br /><li>Tooltip Column: <strong>HIREDATE</strong><br /></li></ol><br /><p>Run the page and confirm that your tree appears. When you right click on a node, you should only see that standard right click options of whatever browser you are using.<br /></p><br /><br /><br /><h2>Create Context Menu<br /></h2><br /><p>Now for the magic! By sprinkling a little JavaScript on the page here and there, we will get a nice right click context menu. First edit the tree region and give the region a static ID of EMP2 as in figure 1. We need this static ID to make it easier to write JavaScript and select this region with jQuery.<br /></p><br /><h3>Figure 1<br /></h3><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-sHib-fHb1CVMcUDq36dSJqto2D9ACUTjYBxaeMCFXDmyaAFFKPCu3Ewn5F1_rBl3MCyfFHPJSK0KA3SlgwvdgD-HNQlWfZ2WNT7dDNr0_9hFmLEjTAuYM_1eKzUFC2A-nyzNsngILctz/s1600/staticID.png"><img style="WIDTH: 400px; HEIGHT: 160px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5516812598332690722" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-sHib-fHb1CVMcUDq36dSJqto2D9ACUTjYBxaeMCFXDmyaAFFKPCu3Ewn5F1_rBl3MCyfFHPJSK0KA3SlgwvdgD-HNQlWfZ2WNT7dDNr0_9hFmLEjTAuYM_1eKzUFC2A-nyzNsngILctz/s400/staticID.png" /></a><br /><br /><br /><p><br /></p><br /><p>Now you just need to sprinkle a little JavaScript on the page! Edit the page definition of page one and add the code in code listing 2 into the Function and Global Variable Declaration text area and the code in code listing 3 into the Execute when Page Loads text area.<br /></p><br /><h3>Code Listing 2<br /><pre class="javascript" name="code"><br />function doAction(pNode,pTree,a){<br /> var l_action;<br /> var l_id;<br /><br /> l_id = pNode.attr("id");<br /><br /> if (a=="create") { l_action = "f?p="+$v('pFlowId')+":2:"+$v('pInstance')+":::2:P2_MGR:"+l_id }<br /> if (a=="delete") { deleteEmp(pNode,l_id); }<br /> if (a=="edit") { l_action = "f?p="+$v('pFlowId')+":2:"+$v('pInstance')+"::::P2_EMPNO:"+l_id }<br /><br /> if (l_action != null) {document.location.href=l_action; }<br />}<br /></pre><br /><br /></h3><br /><h3>Code Listing 3<br /></h3><br /><pre class="javascript" name="code"><br />var lTreeContextMenu={<br /> items:{create:false,rename:false,remove:false,<br /> contextmenu_create:{<br /> label:"<strong>Add Employee</strong>",<br /> icon: "",<br /> visible: true,<br /> action: function(pNode, pTree){doAction(pNode, pTree, "create");}<br /> },<br /> contextmenu_delete:{<br /> label:"<strong>Delete</strong>",<br /> icon: "",<br /> visible: true,<br /> action: function(pNode, pTree){doAction(pNode, pTree, "delete");}<br /> },<br /> contextmenu_edit:{<br /> label:"<strong>Edit</strong>",<br /> icon: "",<br /> visible: true,<br /> action: function(pNode, pTree){doAction(pNode, pTree, "edit");}<br /> }<br />}};<br /><br /> // use jsTree to render the tree<br /> var lTreeSel = apex.jQuery("#EMP2").find("div.tree");<br /> var lTreeId = lTreeSel.attr("id");<br /> var lDataId = lTreeId.replace("tree","");<br /> var lTreeData = eval("l"+lDataId+"Data");<br /> var lTree = lTreeSel.tree({<br /> data:{<br /> type:"json",<br /> async:true,<br /> opts:{<br /> "static":lTreeData,<br /> isTreeLoaded:false,<br /> method:"POST",<br /> url:"wwv_flow.show"<br /> }<br /> },<br /> root:{<br /> draggable:false,<br /> valid_children: "folder"<br /> },<br /> folder:{<br /> valid_children: "file"<br /> },<br /> file:{<br /> valid_children: "none",<br /> max_children: 0,<br /> max_depth:0<br /> },<br /> opened:["7839"],<br /> plugins:{contextmenu:lTreeContextMenu}<br /> });<br /><br /> $.showTooltip = function(pEvent) {<br /> var lAction = apex.jQuery(pEvent.target).attr("tooltip");<br /> if (lAction && lAction != "") {<br /> toolTip_enable(pEvent,this,apex.jQuery(this).attr("tooltip"));<br /> }<br /> }; // showTooltip<br /><br /> // Bind Tooltips for tree nodes<br /> apex.jQuery('a[tooltip]', lTreeSel).bind("mouseover", $.showTooltip);<br /><br /> // Hack for right click problem on selected node<br /> apex.jQuery("#EMP2").find("a").live("mouseup",function() {apex.jQuery("#EMP2").find("a").removeClass()});<br /></pre><br /><br /><p>Now when you run the page you should see a right click context menu when you right click on a node in your tree, like figure 2. Note that the Add Employee and Edit actions are implemented and working. The delete action is not yet working, that will be added next.<br /></p><br /><br /><br /><h3>Figure 2<br /></h3><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoA96ee-zfERtMJf5KE50xELNaxD5sU9pM_Vy7u6bwKyHUs08o2_WvLGCRMB3NQmX54bTmITA0p0sU4t3i1qL8AjI1H3cuJzuzFGjXOYfGX8D7AjmLdR3a3dUWvP-LGkHYUAPBAPzRw9gu/s1600/contextMenu.png"><img style="WIDTH: 400px; HEIGHT: 210px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5516812605370163138" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoA96ee-zfERtMJf5KE50xELNaxD5sU9pM_Vy7u6bwKyHUs08o2_WvLGCRMB3NQmX54bTmITA0p0sU4t3i1qL8AjI1H3cuJzuzFGjXOYfGX8D7AjmLdR3a3dUWvP-LGkHYUAPBAPzRw9gu/s400/contextMenu.png" /></a><br /><br /><h2>Implement Delete Action<br /></h2><br />Technically the delete action is already implemented. You could edit the employee and just click delete on the next page. What sounds like more fun is to call an on demand process using AJAX from some JavaScript, and then use jQuery to remove the node from the tree, display a confirmation message, all without doing a page submit. First things first though, create a region that will hold the message specifying the following options:<br /><ol><br /><li>Region Type: <strong>HTML</strong><br /></li><br /><li>Title: <strong>Message Container</strong><br /></li><br /><li>Region Template: <strong>No Template</strong><br /></li><br /><li>Sequence: <strong>5</strong><br /></li><br /><li>Region Source: See Code Listing 4<br /><br /><br /></li></ol><br /><h3>Code Listing 4<br /></h3><br /><pre class="html" name="code"><br /><div class="success" id="success-message" style="display:none;"><br /> <img src="#IMAGE_PREFIX#delete.gif" onclick="apex.jQuery('#success-message').hide()" style="float:right;" class="remove-message" alt="" /><br /><div id="theMessage">This is a placeholder for messages</div><br /></div><br /></pre><br /><br /><br /><p>Now we have a place for messages. Next, create a process on page 1 with the following options:<br /></p><br /><ol><br /><li>Process Type: <strong>PL/SQL</strong><br /></li><br /><li>Name: <strong>DELETE_EMPLOYEE</strong><br /></li><br /><li>Point: <strong>On Demand – Run this process when requested by AJAX</strong><br /></li><br /><li>PL/SQL Page Process: See Code Listing 5<br /><br /></li></ol><br /><h3>Code Listing 5<br /></h3><br /><pre class="sql" name="code"><br />begin<br /> delete from emp2 where empno = apex_application.g_x01;<br /> owa_util.mime_header('text/xml', FALSE );<br /> htp.p('Cache-Control: no-cache');<br /> htp.p('Pragma: no-cache');<br /> owa_util.http_header_close;<br /> htp.p('{result:"success",message:"Employee successfully deleted"}');<br />exception when others then<br /> owa_util.mime_header('text/xml', FALSE );<br /> htp.p('Cache-Control: no-cache');<br /> htp.p('Pragma: no-cache');<br /> owa_util.http_header_close;<br /> htp.p('{result:"failed",message:"Error deleting employee: '||sqlerrm||'"}');<br />end;<br /></pre><br /><br /><p>Finally, you add the JavaScript to do the AJAX call, display the result message, and remove the node from the tree. Edit the page attributes and add the code in code listing 6 in the Function and Global Variable Declaration text area before the existing doAction function.<br /></p><br /><h3>Code Listing 6<br /></h3><br /><pre class="javascript" name="code"><br />function confirmSubmit(){<br />var agree=confirm("Are you sure you wish to continue and delete?");<br />if (agree)<br /> return true ;<br />else<br /> return false ;<br />}<br /><br />function deleteEmp(pNode,pId){<br /> var lTest = confirmSubmit();<br /> if (lTest) {<br /> var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=DELETE_EMPLOYEE',$v('pFlowStepId'));<br /> get.addParam('x01',pId);<br /> gReturn = get.get();<br /> var j = eval("("+gReturn+")");<br /> apex.jQuery("#theMessage").text(j.message);<br /> apex.jQuery("#success-message").show();<br /> if (j.result == "success") {<br /> pNode.remove();<br /> }<br /><br /> get = null;<br /> }<br />}<br /></pre><br /><br /><br /><p>Now run the page and unroll Clark. Right click on Miller and choose delete. Confirm the delete and the result should be similar to figure 3.<br /><br /></p><br /><h3>Figure 3<br /></h3><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQMkwEb1Oj7RCUWwf-dMEmaxM6F9qTxl766r_HPLcZ4hnkhLSd2gNT8m2vHg4R2ghmuWq5ncXFCvO-_n4Kv9ZLtzCf3Cw_H8yXU8tXtc7dD0lwODcSZw7KNvcyM7L0lG1LbdoTwBbtnd-/s1600/delete.png"><img style="WIDTH: 400px; HEIGHT: 339px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5516812612563742018" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQMkwEb1Oj7RCUWwf-dMEmaxM6F9qTxl766r_HPLcZ4hnkhLSd2gNT8m2vHg4R2ghmuWq5ncXFCvO-_n4Kv9ZLtzCf3Cw_H8yXU8tXtc7dD0lwODcSZw7KNvcyM7L0lG1LbdoTwBbtnd-/s400/delete.png" /></a><br /><br /><br /><p><br /></p></span></div></div></div>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com8tag:blogger.com,1999:blog-6139250371277978964.post-25947387219948940692010-07-06T14:53:00.000-04:002011-01-04T16:19:47.875-05:00Application Express 4.0 Web Services Evaluation GuideI just returned from <a href="http://www.odtugkaleidoscope.com/">ODTUG Kaliedoscope 2010</a>, (awesome event, best one I have been to), and promised during my presentation that the Application Express 4.0 Web Services Evaluation Guide would be posted on the <a href="http://www.oracle.com/technetwork/developer-tools/apex/application-express/integration-086636.html">Application Express Web Services Integration</a> page on OTN. Well it now is, so I kept my promise. ;)<br /><br />If you missed me at ODTUG, you can see me give a very similar presentation this year at <a href="http://www.oracle.com/us/openworld/index.htm">Oracle Open World</a>. The session is at 12:30 on Thursday September 23rd, so don't get too crazy at the appreciation event the night before!<br /><br /><strong>Update 7/28/2010: </strong>A patch set exception was created for the issue the Roel reported in the comments below. Log on to Metalink and search for 9848562.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com11tag:blogger.com,1999:blog-6139250371277978964.post-68433428235505586692010-02-26T16:06:00.000-05:002010-02-26T16:21:30.574-05:00Application Express 4.0 Early Adopter Phase II (EA2) AvailableThe <a href="http://tryapexnow.com/apex">Application Express 4.0</a> Early Adopter Phase II (EA2) is now available. Like EA1, this instance is running on Amazon EC2. The beauty of Amazon's <a href="http://aws.amazon.com/ec2/#features">elastic <span id="SPELLING_ERROR_0" class="blsp-spelling-error">IP</span> </a>feature is that we could work on the EA2 instance and get it completely ready, then associate the elastic <span id="SPELLING_ERROR_1" class="blsp-spelling-error">IP</span> with the new instance, making the switch in less than 60 seconds. You can still access <a href="http://184.73.244.154/apex">EA1 </a>for the next couple of weeks in case you need anything from that instance. You will need to sign up for a new workspace on EA2.<br /><br />One nugget I would pass on is that if you run Oracle in the cloud and use <a href="http://aws.amazon.com/ebs/">Elastic Block Storage </a>for your <span id="SPELLING_ERROR_2" class="blsp-spelling-corrected">data files</span>, you should also change the parameter <em>diagnostic_<span id="SPELLING_ERROR_3" class="blsp-spelling-error">dest</span></em> to point to your <span id="SPELLING_ERROR_4" class="blsp-spelling-error">EBS</span> volume instead of the volatile volume that only lives with the instance. The reason is that you could fill up that volume pretty quickly if there is a lot of action on your instance and cause your database to shutdown.<br /><br />Have fun with EA2 and especially kicking the tires of <a href="http://www.oracle.com/technology/products/database/application_express/apex_sod.html"><span id="SPELLING_ERROR_5" class="blsp-spelling-error">Websheets</span></a>!Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com2tag:blogger.com,1999:blog-6139250371277978964.post-60270280471720386272010-01-08T08:52:00.000-05:002010-01-08T09:07:24.590-05:00OTN Developer Days in NYCAre you in the NY, NY area? If so you should definitely attend the free <a href="http://www.oracle.com/webapps/events/EventsDetail.jsp?p_eventId=101955&src=6773869&src=6773869&Act=85">OTN Developer Day- Hands-on Oracle Database 11g Applications Development</a> event at the New York Marriot Marquis on January 13, 2010. I will not be there, but much smarter colleagues of mine will like Mike Hichwa (VP of Development Tools, father of Application Express), Marc Sewtz, David Peake and Christina Cho.<br /><br /><br />Bring your own laptop for the labs.<br /><br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvnXLA0fkeIHl-_LFkLTWZ51Dg46D1Dq_NIdQ9G_WjkeBSR_PJuxnVyQNvAaGMF2n9G4XBSVt-b3S3xz7Z4s3j095RRo7paAYo9dTKAiGN3ByEY89lRYfrY_Ivi2ylWyWmupigbz7-s05-/s1600-h/odd_apex.png"><img style="WIDTH: 400px; HEIGHT: 148px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5424368720298597490" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvnXLA0fkeIHl-_LFkLTWZ51Dg46D1Dq_NIdQ9G_WjkeBSR_PJuxnVyQNvAaGMF2n9G4XBSVt-b3S3xz7Z4s3j095RRo7paAYo9dTKAiGN3ByEY89lRYfrY_Ivi2ylWyWmupigbz7-s05-/s400/odd_apex.png" /></a>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-37409297631923052762009-12-21T14:30:00.001-05:002009-12-21T14:34:44.936-05:00Application Express 4.0 EA Running on Amazon EC2The Application Express 4.0 evaluation instance is running on an Amazon EC2 instance. You can access it at <a href="http://tryapexnow.com/">http://tryapexnow.com</a>. You may also be interested in checking out the APEX 4.0 Web Services Evaluation Guide <a href="http://tryapexnow.com/APEX40WebServicesEvaluationGuide.doc">here</a>.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-8794177341465033102009-11-20T11:00:00.000-05:002009-11-20T11:12:28.099-05:00flex_ws_api now on samplecode.oracle.com<a href="http://tylermuth.wordpress.com/">Tyler </a>recently made me aware of <a href="http://samplecode.oracle.com/">http://samplecode.oracle.com/</a>. It is a great place to share code projects, allow others to contribute and comment through discussion forums. I have set up a project for the <a href="https://flex-ws-api.samplecode.oracle.com/">flex_ws_api</a> and all further development will take place there. I have created discussions for general questions, bug reports, and enhancement requests. Feel free to participate there. All you need is an OTN account to login.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com0tag:blogger.com,1999:blog-6139250371277978964.post-83459888775477623162009-10-23T16:36:00.001-04:002009-10-26T09:38:03.554-04:00REST Now Supported in flex_ws_api and Other Good Stuff<span xmlns=""><p>I have finally added support for consuming RESTful Web services in the <a href="http://jastraub.blogspot.com/2008/06/flexible-web-service-api.html">flex_ws_api API</a>. I have also added new globals in the API to keep track of cookies, HTTP headers and the response code returned from a service. There is also a global you can populate prior to calling any of the make_request procedure/functions that will send cookies along with the request to the Web service.<br /></p><p>To demonstrate using the new features of the API, I will walk you through creating a new application that will call the RESTful version of <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2432&categoryID=19">Amazon's Product Advertising API</a>. You may recall <a href="http://jastraub.blogspot.com/2009/07/hmacsha256-in-plsql.html">from a previous post</a> that Amazon now requires that all requests to this API are signed with the developer's secret key. This example will assume that you have compiled the following in your schema: the new flex_ws_api, the java source hmacSHA256, the pl/sql function hmacSHA256, and finally the amazon_signature function.<br /></p><p>First create a new application with one blank page called Product Search. Modify the application attributes and add the following substitutions:<br /></p><ol><li>AWSACCESSKEY<br /></li><li>ASSOCIATETAG<br /></li><li>AWSSECRETKEY<br /></li></ol><p>Enter the appropriate values with the values that match your AWS credentials. You will need to sign up for an <a href="http://aws.amazon.com/">AWS Access Key ID</a> which will also give you your secret code and you also should sign up to be an <a href="http://associates.amazon.com/exec/panama/associates/apply">associate</a> which will give you your associate tag.<br /></p><p>Next create an HTML region called Product Search (if it was not already created by the create application wizard) and place the following items in that region:<br /></p><ol><li>Name: <strong>P1_KEYWORDS</strong>, Display As: <strong>Text Field</strong><br /> </li><li>Name: <span style=";font-family:Arial;font-size:9;color:black;" ><strong>P1_SEARCHINDEX</strong>, Display As: <strong>Select List</strong>, List of Values – Display Extra Values: <strong>No</strong>, List of values definition: <strong>STATIC2:All;All,Apparel;Apparel,Automotive;Automotive,Baby;Baby,Beauty;Beauty,Books;Books,Classical;Classical,DigitalMusic;DigitalMusic,DVD;DVD,Electronics;Electronics,GourmetFood;GourmetFood,HealthPersonalCare;HealthPersonalCare,HomeGarden;HomeGarden,Industrial;Industrial,Jewelry;Jewelry,KindleStore;KindleStore,Kitchen;Kitchen,Magazines;Magazines,Merchants;Merchants,Miscellaneous;Miscellaneous,MP3Downloads;MP3Downloads,Music;Music,MusicalInstruments;MusicalInstruments,MusicTracks;MusicTracks,OfficeProducts;OfficeProducts,OutdoorLiving;OutdoorLiving,PCHardware;PCHardware,PetSupplies;PetSupplies,Photo;Photo,Shoes;Shoes,SilverMerchants;SilverMerchants,Software;Software,SportingGoods;SportingGoods,Tools;Tools,Toys;Toys,UnboxVideo;UnboxVideo,VHS;VHS,Video;Video,VideoGames;VideoGames,Watches;Watches,Wireless;Wireless,WirelessAccessories;WirelessAccessories</strong></span><br /> </li><li><span style=";font-family:Arial;font-size:9;color:black;" >Name: <strong>P1_TIMESTAMP</strong>, Display As: <strong>Hidden and Protected</strong></span><br /> </li></ol><p>Create a Submit button on the page that submits the page and branches back to page 1.<br /></p><p>You must compute the value of P1_TIMESTAMP to a format that Amazon is expecting. The computation includes a GMT offset at the end so your computation will depend on where your database server is relative to GMT. For me it was -08:00. Create a computation on page 1 with the following attributes:<br /></p><ol><li>Item Name: <strong>P1_TIMESTAMP</strong><br /> </li><li>Type: <strong>PL/SQL Function Body</strong><br /> </li><li>Computation Point: <strong>After Submit</strong><br /> </li><li>Computation: <strong>return to_char(sysdate + 8/24,'YYYY-MM-DD')||'T'||to_char(sysdate,'hh24:mi:ss')||'-08:00';</strong><br /> </li></ol><p>Now you create the process on that page that uses the flex_ws_api to call the Amazon Product Advertising API REST Web service. Create a process on the page with the following attributes:<br /></p><ol><li>Name: <strong>Call Amazon Product Search API</strong><br /> </li><li>Type: <strong>PL/SQL anonymous block</strong><br /> </li><li>Process Point: <strong>On Submit – After Computations and Validations</strong><br /> </li><li>Source: <strong><see code listing 1></strong><br /> </li><li>Conditional Processing, When Button Pressed: <strong>SUBMIT</strong><br /> </li></ol><h2>Code Listing 1, Call Amazon Product Search API Process<br /></h2><pre class="sql" name="code"><br />declare<br /> l_signature varchar2(4000);<br /> l_response clob;<br /> l_parm_name_tab wwv_flow_global.vc_arr2;<br /> l_parm_val_tab wwv_flow_global.vc_arr2;<br /> i number;<br /> secure varchar2(1);<br />begin<br /><br /> --compute the signature<br /> l_signature := amazon_signature('GET'||chr(10)||'ecs.amazonaws.com'||chr(10)||'/onca/xml'||chr(10)||'AWSAccessKeyId='||:AWSACCESSKEY||'&AssociateTag='||:ASSOCIATETAG||'&Keywords='||replace(:P1_KEYWORDS,' ','%20')||'&Operation=ItemSearch&ResponseGroup=ItemAttributes%2CImages&SearchIndex='||:P1_SEARCHINDEX||'&Service=AWSECommerceService&Timestamp='||apex_util.url_encode(:P1_TIMESTAMP)||'&Version=2009-03-31',:AWSSECRETKEY);<br /><br /> --create the tables of parameter names and values<br /> l_parm_name_tab := apex_util.string_to_table('Service:Version:Operation:Keywords:SearchIndex:AWSAccessKeyId:AssociateTag:ResponseGroup:Timestamp:Signature');<br /> --need to use ~ instead of : for separator since timestamp will contain :<br /> l_parm_val_tab := apex_util.string_to_table('AWSECommerceService~2009-03-31~ItemSearch~'||:P1_KEYWORDS||'~'||:P1_SEARCHINDEX||'~'||:AWSACCESSKEY||'~'||:ASSOCIATETAG||'~ItemAttributes,Images~'||:P1_TIMESTAMP,'~');<br /> --need to add l_signature to the table separately, it may contain any character<br /> l_parm_val_tab(l_parm_val_tab.count + 1) := l_signature;<br /><br /> --make the REST request<br /> l_response := flex_ws_api.make_rest_request(<br /> p_url => 'http://ecs.amazonaws.com/onca/xml',<br /> p_http_method => 'GET',<br /> p_parm_name => l_parm_name_tab,<br /> p_parm_value => l_parm_val_tab );<br /><br /> --populate a collection with the response<br /> apex_collection.create_or_truncate_collection('P1_ITEMSEARCH_RESPONSE');<br /> apex_collection.add_member(<br /> p_collection_name => 'P1_ITEMSEARCH_RESPONSE',<br /> p_clob001 => l_response );<br /><br /> --populate a collection for any response http headers returned<br /> apex_collection.create_or_truncate_collection('P1_RESP_HEADERS');<br /><br /> for i in 1.. flex_ws_api.g_headers.count loop<br /> apex_collection.add_member(<br /> p_collection_name => 'P1_RESP_HEADERS',<br /> p_c001 => flex_ws_api.g_headers(i).name,<br /> p_c002 => flex_ws_api.g_headers(i).value,<br /> p_c003 => flex_ws_api.g_status_code);<br /> end loop;<br /><br />end;<br /></pre><p>Next you create two SQL Report regions. The first one reports on the response from the Web service and shows the products that match the search term and the second shows the HTTP headers that are returned with the response. Create a SQL Report region with the following attributes:<br /></p><ol><li>Title: <strong>Results</strong><br /> </li><li>Type: <strong>SQL Query</strong><br /> </li><li>Source: <strong><see code listing 2></strong><br /> </li><li>Conditional Display, Condition Type: <strong>PL/SQL Expression</strong><br /> </li><li>Conditional Display, Expression 1: apex_collection.collection_exists('P1_ITEMSEARCH_RESPONSE')<br /></li></ol><h2>Code Listing 2, Results SQL Query<br /></h2><br /><pre class="sql" name="code"><br />select extractValue(value(t),'/*/ASIN','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"') ASIN<br /> , extractValue(value(t),'/*/DetailPageURL','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"') DetailPageURL<br /> , extractValue(value(t),'/*/ItemAttributes/Title','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"') Title<br /> , '<img src="'||nvl(extractValue(value(t),'/*/SmallImage/URL','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"'),'http://ec1.images-amazon.com/images/G/01/x-locale/detail/thumb-no-image._V47060337_.gif')||'" width="'||nvl(extractValue(value(t),'/*/SmallImage/Width','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"'),'50')||'" height="'||nvl(extractValue(value(t),'/*/SmallImage/Height','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"'),'60')||'" />' "Image"<br /> , extractValue(value(t),'/*/ItemLinks/ItemLink[4]/URL','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"') Link<br />from wwv_flow_collections c,<br /> table(xmlsequence(extract(xmltype.createxml(c.clob001),'//Item','xmlns="http://webservices.amazon.com/AWSECommerceService/2009-03-31"'))) t<br />where c.collection_name = 'P1_ITEMSEARCH_RESPONSE'<br /></pre><p>The query above pulls out the ASIN, detail page URL, title, small image and wish list link from the XML document. You want to create links for the title point to the detail page and a link for the wishlist in your report. Make the following changes to the Results report by click on the Report link on the page definition.<br /></p><ol><li>Uncheck Show for the column DETAILPAGEURL<br /></li><li>Enter the following HTML Expression for TITLE column: <strong><a href="#DETAILPAGEURL#">#TITLE#</a></strong><br /> </li><li>Enter the following HTML Expression for LINK column: <strong><a href="#LINK#">[Add to Wishlisth]</a></strong><br /> </li></ol><p>Create a SQL Report region for the HTTP headers with the following attributes:<br /></p><ol><li>Title: <strong>Headers</strong><br /> </li><li>Type: <strong>SQL Query</strong><br /> </li><li>Source: <strong><see code listing 3></strong><br /> </li><li>Conditional Display, Condition Type: <strong>PL/SQL Expression</strong><br /> </li><li>Conditional Display, Expression 1: apex_collection.collection_exists('P1_RESP_HEADERS')<br /></li></ol><h2>Code Listing 3, Header SQL Query<br /></h2><pre class="sql" name="code"> select c001 name, c002 value, c003 status_code<br />from apex_collections<br />where collection_name = 'P1_RESP_HEADERS'<br /></pre><p>Now run the page, enter a search term, choose a category and click Submit. You should see a page similar to the one below. That's all there is to it!<br /></p><p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieNF6q3qUyYJetHrU932eisUlr71bkidiTxNXI-2jTPYBoo9i-lBLM7a8CGnoB0RJ1W9-VV02_vhhQRO5D2V4M8uSL2mYrWsh7Yd9YZz5XHIjDalCCq5gbGDktKulSukmPvab92gRtEp9W/s1600-h/AmazonProductAPIBlogPost1.jpg"><img style="cursor: pointer; width: 400px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieNF6q3qUyYJetHrU932eisUlr71bkidiTxNXI-2jTPYBoo9i-lBLM7a8CGnoB0RJ1W9-VV02_vhhQRO5D2V4M8uSL2mYrWsh7Yd9YZz5XHIjDalCCq5gbGDktKulSukmPvab92gRtEp9W/s400/AmazonProductAPIBlogPost1.jpg" alt="" id="BLOGGER_PHOTO_ID_5395898159374634834" border="0" /></a></p><p></p></span>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com11tag:blogger.com,1999:blog-6139250371277978964.post-6354273586136473782009-07-24T11:34:00.001-04:002009-07-24T11:55:32.160-04:00HMAC_SHA256 in PL/SQL<span xmlns=""><p>I have been working on an Application Express 4.0 feature to support consuming REST Web services. REST Web services use a simpler architecture than the popular SOAP style Web services. Instead of posting some big XML document wrapped in a SOAP Envelope, REST requests are typically done by passing name/value pairs in the query string of a URL.<br /></p><p>To prove that the support for REST I am building in Application Express is useful, I have been working with popular public REST Web services offered by Yahoo, Google and Amazon. I built a similar application to the <a href="http://www.oracle.com/technology/products/database/application_express/packaged_apps/integration.html">Amazon Store</a> sample application using the REST APIs. Everything was going great until I received the following email from Amazon.<br /></p><p>"Dear Product Advertising API Developer,<br /></p><p>We wanted to remind you that all Product Advertising API developers will be required to authenticate all calls to the Product Advertising API by August 15, 2009. We noticed that requests with your AWS Access Key ID are not being signed and, while you have more than 60 days until the date on which authentication is required, we are, as a courtesy, sending you this email to remind you of the new authentication requirement. Please remember that calls to the Product Advertising API that are not signed will not be processed after August 15, 2009."<br /></p><p>What do they mean I need to sign my requests? Luckily they provided some links for <a href="http://www.amazon.com/gp/r.html?R=16V6GMZOI82UF&C=2VEYJ1HBZV7BE&H=LATBAM3EYCAQTANAALJJRR7GI5WA&T=C&U=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fr.html%2Fref%3Dpe_53700_12281680%3FR%3D3Q89S9WPYQKE1%26C%3D3SOKYNFG0JD02%26H%3DAFX3IIIM5CBYLVKZ1KBCMMEKQNOA%26T%3DTC%26U">developer resources</a> on how to construct signed requests. In a nutshell, you must byte order all of your parameters, add a Timestamp parameter and then you create a base64-encoded HMAC_SHA256 signature using your <a href="https://aws-portal.amazon.com/gp/aws/developer/registration/index.html">AWS secret key</a>. Should not be a problem. I recently added support for parameters in REST requests to be populated by the result of a function and I am somewhat familiar with the DBMS_CRYPTO package. Unfortunately I quickly found out that DBMS_CYRPTO only supports HMAC_SHA1 and I not so quickly found out that HMAC_SHA1 is not the same as HMAC_SHA256. Am I stuck?<br /></p><p>I <a href="http://www.bing.com/">binged</a> (Google gets enough love and Microsoft can use the help after their most recent earnings results) for HMAC_SHA256 and PL/SQL and found <a href="http://www.orafaq.com/forum/t/71097/2/">this</a> forum post. This guy wanted to do exactly what I need to do. Someone suggested that he create a Java stored procedure and then he responded with some Java code example with and hmacSHA256 function. Unfortunately no-one could give him an example of exactly how to create that Java stored procedure and then use it in PL/SQL. That's when I remembered that my good friend and colleague Joel Kallman <a href="http://joelkallman.blogspot.com/2008/04/zip-it.html">wrote</a> about creating a Java stored procedure to create a zip file of BLOB's.<br /></p><p>Well, surely I can follow Joel's example as a cookbook and do the same thing with this hmacSHA256 function, right? The answer is yes, after spending more time than I probably should have (don't tell Joel if you see him), but hey, I had to prove that this REST stuff would actually be useful to customers. If they can't sign their requests, they won't be able to use Application Express to build cool applications that interact with Amazon Web Services. (At least that is my attempt at invoking what another colleague calls The Oracle Justification Server.)<br /></p><p>First, start by compiling the following Java source.<br /></p><h2>Code listing 1, java source hmacSHA256<br /></h2><p><br /><pre class="sql" name="code"><br />create or replace and compile java source named hmacSHA256 as<br /><br />import java.io.*;<br />import java.net.*;<br />import java.security.*;<br />import java.util.*;<br /><br />public class hmacSHA256 {<br /> public static String encrypt(<br /> String message,<br /> String keyStr) {<br /><br /> //get the bytes of the keyStr<br /> byte[] key = keyStr.getBytes();<br /> // Start by getting an object to generate SHA-256 hashes with.<br /> MessageDigest sha256 = null;<br /> try {<br /> sha256 = MessageDigest.getInstance("SHA-256");<br /> } catch (NoSuchAlgorithmException e) {<br /> throw new java.lang.AssertionError(".hmacSHA256(): SHA-256 algorithm not found!");<br /> }<br /> // Hash the key if necessary to make it fit in a block (see RFC 2104).<br /> if (key.length > 64) {<br /> sha256.update(key);<br /> key = sha256.digest();<br /> sha256.reset();<br /> }<br /><br /> // Pad the key bytes to a block (see RFC 2104).<br /> byte block[] = new byte[64];<br /> for (int i = 0; i < key.length; ++i) block[i] = key[i];<br /> for (int i = key.length; i < block.length; ++i) block[i] = 0;<br /><br /> // Calculate the inner hash, defined in RFC 2104 as<br /> // SHA-256(KEY ^ IPAD + MESSAGE)), where IPAD is 64 bytes of 0x36.<br /> for (int i = 0; i < 64; ++i) block[i] ^= 0x36;<br /> sha256.update(block);<br /> try {<br /> sha256.update(message.getBytes("UTF-8"));<br /> } catch (UnsupportedEncodingException e) {<br /> throw new java.lang.AssertionError(<br /> "ITunesU.hmacSH256(): UTF-8 encoding not supported!");<br /> }<br /> byte[] hash = sha256.digest();<br /> sha256.reset();<br /><br /> // Calculate the outer hash, defined in RFC 2104 as<br /> // SHA-256(KEY ^ OPAD + INNER_HASH), where OPAD is 64 bytes of 0x5c.<br /> for (int i = 0; i < 64; ++i) block[i] ^= (0x36 ^ 0x5c);<br /> sha256.update(block);<br /> sha256.update(hash);<br /> hash = sha256.digest();<br /><br /> // The outer hash is the message signature...<br /> // convert its bytes to hexadecimals.<br /> char[] hexadecimals = new char[hash.length * 2];<br /> for (int i = 0; i < hash.length; ++i) {<br /> for (int j = 0; j < 2; ++j) {<br /> int value = (hash[i] >> (4 - 4 * j)) & 0xf;<br /> char base = (value < 10) ? ('0') : ('a' - 10);<br /> hexadecimals[i * 2 + j] = (char)(base + value);<br /> }<br /> }<br /><br /> // Return a hexadecimal string representation of the message signature.<br /> return new String(hexadecimals);<br /> }<br />}<br />/<br /></pre><br /><p></p><p>Next you create a standard PL/SQL function that uses the java source as in the following code listing.<br /></p><h2>Code listing 2, PL/SQL hmacSHA256 function<br /></h2><p><br /><pre class="sql" name="code"><br />create or replace function hmacSHA256(<br /> p_string in varchar2,<br /> p_key in varchar2) return varchar2<br />as language java<br /> name 'hmacSHA256.encrypt(<br /> java.lang.String,<br /> java.lang.String) return String';<br />/<br /></pre><br /><p></p><p>Finally, you create a function that takes in the string to sign, your AWS Secret Key, and then creates the HMAC_SHA256 signature.<br /></p><h2>Code listing 3, amazon_signature function<br /></h2><p><br /><pre class="sql" name="code"><br />create or replace function amazon_signature(<br /> p_string in varchar2,<br /> p_key in varchar2) return varchar2<br />as<br /> encrypted_raw raw(2000);<br /> output_string varchar2(32000);<br />begin<br /><br /> encrypted_raw := hmacSHA256(p_string,p_key);<br /> output_string := UTL_I18N.RAW_TO_CHAR (utl_encode.base64_encode(encrypted_raw), 'AL32UTF8');<br /><br /> return output_string;<br /><br />end amazon_signature;<br />/<br />show errors<br /></pre><br /><p></p><p>Now let's test all this out. Amazon provides a nice self contained Web page <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2609&categoryID=14">utility</a> that uses Javascript to help you create signed requests. I will use 123456 as my AWS Access Key ID and abcdefg as my AWS Secret Access Key. Plug in the following URL in the Unsigned URL text area:<br /></p><p><a href="http://ecs.amazonaws.com/onca/xml?Timestamp=2009-07-24T06%3A35%3A14-08%3A00&Service=AWSECommerceService&Version=2009-03-31&Operation=ItemSearch&ResponseGroup=ItemAttributes,Images&Keywords=liberty+and+tryanny&SearchIndex=Books&AWSAccessKeyId=123456&AssociateTag=apex30-20">http://ecs.amazonaws.com/onca/xml?Timestamp=2009-07-24T06%3A35%3A14-08%3A00&Service=AWSECommerceService&Version=2009-03-31&Operation=ItemSearch&ResponseGroup=ItemAttributes,Images&Keywords=liberty+and+tryanny&SearchIndex=Books&AWSAccessKeyId=123456&AssociateTag=apex30-20</a><br /></p><p>This will come up with the following string to sign:<br /></p><p>GET<br /></p><p>ecs.amazonaws.com<br /></p><p>/onca/xml<br /></p><p>AWSAccessKeyId=123456&AssociateTag=apex30-20&Keywords=liberty%20and%20tryanny&Operation=ItemSearch&ResponseGroup=ItemAttributes%2CImages&SearchIndex=Books&Service=AWSECommerceService&Timestamp=2009-07-24T06%3A35%3A14-08%3A00&Version=2009-03-31<br /></p><p>And will produce the following Signature parameter:<br /></p><p><span style="color:red;">uMJX4cN6EXHyTUrC03Ae9hAcGdTnAHI0KqtovwQUHP8%3D<br /></span></p><p>If I take the same string to sign and AWS Secret Key of abcdefg and run it through amazon_signature, I get the following results:<br /></p><h2>Code listing 4, result of amazon_signature function<br /></h2><p><br /><pre class="sql" name="code"><br />jason@APX11W> declare<br /> 2 l_token varchar2(4000);<br /> 3 begin<br /> 4 l_token := amazon_signature('GET<br /> 5 ecs.amazonaws.com<br /> 6 /onca/xml<br /> 7 AWSAccessKeyId=123456&AssociateTag=apex30-20&Keywords=liberty%20and%20tryanny&Operation=ItemSearch&ResponseGroup=It<br />emAttributes%2CImages&SearchIndex=Books&Service=AWSECommerceService&Timestamp=2009-07-24T06%3A35%3A14-08%3A00&Version=20<br />09-03-31','abcdefg');<br /> 8 dbms_output.put_line(l_token);<br /> 9 end;<br /> 10 /<br />uMJX4cN6EXHyTUrC03Ae9hAcGdTnAHI0KqtovwQUHP8=<br /><br />PL/SQL procedure successfully completed.<br /></pre><br /><p></p><p>The only difference in the result is the very end. Prior to using the signature, it must be URL encoded. If you run the string uMJX4cN6EXHyTUrC03Ae9hAcGdTnAHI0KqtovwQUHP8= through wwv_flow_utilities.url_encode2, you will get uMJX4cN6EXHyTUrC03Ae9hAcGdTnAHI0KqtovwQUHP8%3D. </p></span>Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com11tag:blogger.com,1999:blog-6139250371277978964.post-34531629480861874902009-04-14T09:59:00.000-04:002009-04-14T10:09:30.187-04:00New Web Services Integration White Paper and Sample Application on OTNLate last year I <a href="http://jastraub.blogspot.com/2008/12/more-changes-to-flexwsapi.html">promised </a>a white paper and sample application on integrating Application Express and BI Publisher through Web services. Well five months later (hey, that's less than 1/2 a year), it is now available on the <a href="http://www.oracle.com/technology/products/database/application_express/packaged_apps/integration.html">Application Express Web Services Integration </a>page on <span class="blsp-spelling-error" id="SPELLING_ERROR_0">OTN</span>. The sample application allows you to <span class="blsp-spelling-error" id="SPELLING_ERROR_1">login</span> to a BI Publisher instance as a BI Publisher defined user, browse the folders and reports available to that user, and provides the ability to download the report all from within the Application Express application. The white paper describes in detail how to build the application using PL/<span class="blsp-spelling-error" id="SPELLING_ERROR_2">SQL</span> and the <a href="http://jastraub.blogspot.com/2008/06/flexible-web-service-api.html">flex_<span class="blsp-spelling-error" id="SPELLING_ERROR_3">ws</span>_<span class="blsp-spelling-error" id="SPELLING_ERROR_4">api</span> package</a>. I hope you find it useful.Jason Straubhttp://www.blogger.com/profile/12627913070109819002noreply@blogger.com4