Wednesday, October 24, 2012

APEXBlogs part of odtug.com/apex

Over the last years things changed fast: HTMLDB became APEX, many developers started to use APEX day-in-day-out, the development team released APEX 4.2 a few days ago and the Oracle Cloud is using APEX as a key component...

Oracle Application Express (APEX) matured over the last 8 years and people blogging and using APEX grow exponentially.

In my personal life things changed as well; I co-founded APEX Evangelists, a company 100% focussed on Oracle Application Express (development, consulting, training).  I became a father of a great boy and a wonderful daughter and, despite my long working hours and many travelling, my wife and I are still married and enjoying our time together.

It has always be my dream to bring the whole APEX community together so we share our passion and experience. And I think the APEX community is doing great; from the first APEX Meet-up at Oracle Open World in 2006 where we started with about 10 people till the recent one of a few weeks ago where we were with over 100 people, over the many conferences, especially ODTUG where APEX is huge. I build APEXBlogs to promote APEX and as a platform to share our knowledge (or even to become "the" APEX Portal).

I gave it a lot of thought, and I believe I brought APEXBlogs the furthest I could in the time I had and to take it to another level, things need to change...

Below is a short history in the life of APEXBlogs:

February 05, 2008 - Launch of APEXBlogs.info

Goal was to have "the" portal for the APEX Developer with links to great resources
and a place to see all blogs that write about APEX or APEX related content.
It also acted as a public showcase application of an APEX application.



November 23, 2009 - APEXBlogs also includes twitter messages



March 05, 2011 - APEXBlogs v2 goes live with many new features:

  • global search
  • knowledge base
  • statistics
  • APEX Usage
  • new links
  • Plugins
  • use of interactive reports
  • use of google reader in the backend
  • iPad compatible
  • new theme


April 06, 2011 - Webinar - How APEXBlogs was built

 I explained how I built APEXBlogs and how things looked like behind the scenes


October 25, 2012 - APEXBlogs part of odtug.com/apex

After more than 4,5 years APEXBlogs will move under the umbrella of a the Oracle user group ODTUG.



That's right, APEXBlogs will from now on redirect to odtug.com/apex ...

I believe there should be one Global APEX User Group in the world which has "the" conference and "the" platform where you find everything you need as an APEX developer. Don't get me wrong, I still think having local user groups is very useful too and the official Oracle sites (OTN, apex.oracle.com) are a must visit for every person! But as things start to expand so much, it's good that an organisation follows-up what is going on everywhere, and who's better than ODTUG to do this?

I had many talks with the ODTUG board and I'm convinced the APEX community is even better served when everything is under that flag...

Wednesday, October 17, 2012

Moving your APEX app to the Oracle Cloud

Now that the Oracle Cloud is publicly available, I want to show you what it takes to put your APEX application on there. 

As an example I will use the application "DGTournament" that I created in 2006 to promote APEX and upgraded every two years to the latest version of APEX. I thought this would be a good app to use as there's some legacy code in, but it also contains many new features that came with every release of APEX. Next to that you might actually have played with it, the app/site is still live and we can also do a side-by-side comparison of Amazon EC2 vs Oracle Cloud.

In this first post I want to take my current application with all it's data and move that onto the Oracle Cloud.


You can apply for an account on this link and you will receive some emails when you are ready to go as described in a previous post


Step 2: Connect to the Oracle Cloud from Oracle SQL Developer

Kris Rice did an excellent blog post about it. Next to that post I would definitely recommend reading the Oracle Cloud documentation as it contains important information how to connect with SFTP. You have to reset your password first, to do that you need to connect to IDM, all that is in the doc very well explained.


Step 3: Move your database objects, data and APEX app to the Oracle Cloud

Normally I would take a datapump export of my existing schema and take an export of my APEX application. So that was the route I wanted to follow, however I couldn't find the option to do a datapump import in the Oracle Cloud! (not through the tree, not through the Datapump wizard in SQL Developer)

After looking into the Oracle Cloud documentation again, it said you have to use the Cart option (which you find under the View menu) in SQL Developer. I used that before, I even asked for an enhancement request. 

So I connected to the database DGTournament is currently in and dragged everything from the tree into the Cart. (note that you need to specifically drag the package bodies, otherwise you just have the specifications) I also thought to be smart and dragged my APEX application into the cart (see next screenshot at the bottom)... 


So once everything is in the cart (and you can say you want all data for all tables as well) you can deploy to the cloud by clicking on the cloud icon (top, most left).


Fill out the details of the Oracle Cloud connection and hit Apply. A few minutes later all my database objects and data were in the Oracle Cloud! I was impressed how smooth it was.
The following screenshot shows the deployment overview and I expanded the tables tree of my Oracle Cloud connection so you can see everything is effectively in, even the BLOB columns and data got transferred without any issue.


As I dragged the APEX application in the Cart as well, I thought I would find it in my APEX Builder, but it wasn't there, so you have to manually import your APEX application.

Step 4: Import your APEX application (through the APEX Application Builder)

Importing an APEX app is not a big deal, export your app from one APEX instance and import through the wizards in the other APEX instance and done.


Step 5: Run your APEX application

Next I just ran the application but got an error ... it would have been wonderful if everything just worked, right? The backend was there and the app was there ... unfortunately I got an Oracle error ORA-... (see Step 6).


Step 6: Review (and try to recompile) all invalid database objects

And here is the biggest catch with the Oracle Cloud: some database packages are not available in the Oracle Public Cloud. So for example I recompiled one of my packages and got this error:


So after reviewing my code, following packages I used are not working in the Oracle Cloud:
  • DBMS_OBFUSCATION_TOOLKIT
    • I used this to hash the password
  • DBMS_UTILITY
    • I used it to calculate timings
  • UTL_TCP
    • I used it for crlf (character linefeed)
  • UTL_SMTP
    • I used it to send out mails with attachments
I also had in the APEX application direct calls to my PL/SQL package, for example to show an image I used in the src attribute of the img tab: "#OWNER#.tdg_pkg_content.SHOW_IMAGE?p_image_id=#IMAGE_ID#". But as you can't give the correct grants (to APEX_PUBLIC_USER) this doesn't work either.

Step 7: Make your code "Oracle Public Cloud"-compatible

So this basically means that all the package calls I do, that don't work, I will need to either remove or rewrite to something that does work.

For example the DBMS_UTILITY package I don't really need anymore as you can get timings native in APEX today, so not necessary to calculate yourselves.

The call to UTL_TCP for just the character linefeed I can remove too.

UTL_SMTP is interesting... in 2006 (and later in 2008), when I wrote some part of the application, there wasn't the apex_mail package yet that supported attachments, so that is why I had to use utl_smtp and write everything myself... but even using the apex_mail package wouldn't work as sending mails from the database in general is not supported in the Oracle Cloud. So the only way to solve that issue, is to integrate with a service (for example MailChimp) that sends emails for you.

And showing the images I wouldn't really code anymore using my own procedure either, as you can now use the native BLOB (image) support in APEX.

So that leaves me with DBMS_OBFUSCATION_TOOLKIT which I need to replace by something else that works in the Oracle Cloud.




Step 8: Review and Test the entire application (in all browsers)

There might be some code flying around in your application which should have been in packages (but isn't) or other components of the APEX app that are not compatible, for example some third party plugins which need some specific filesystem files and folders which you can't create in the Oracle Public Cloud.

To identify the code that should be in packages and which might not be compatible I use the APEX Advisor to find those and I did! When you upload your profile picture in DGTournament I create a thumbnail on the fly with ORDSYS.ORDIMAGE... and it looks like that's something you can't use either in the Oracle Public Cloud. It actually remembers me of one of my conversations with the Oracle team during my beta testing; I really would love to see Intermedia and Locator support in the Oracle Cloud as many of my applications are using that... the answer was it might come in the future, but it's not available yet.


For the rest you just need to go through your application and test it...

Step 9: Enjoy the Oracle Public Cloud

Once you have everything running and everything is compatible, you can enjoy the Oracle Public Cloud... Click this link to see DGTournament in action in the Oracle Public Cloud. (note that I didn't correct all incompatibilities yet and didn't upload all external files it needs)

In my next blog posts I will talk about other things like the performance, doing the maintenance etc. ... and my last post will be a conclusion.

Tuesday, October 16, 2012

Integration of Oracle Social Network and APEX

At Oracle Open World (OOW) Martin and I had a lot of fun integrating the Oracle Social Network (OSN) with Oracle Application Express (APEX).

In short there was a developer challenge at OOW where teams had to find a good use case to integrate OSN with the technology of your choice... Martin and I obviously used APEX... and we won! We hacked it together in one night! Jake (one of the organisers) wrote a nice blog post about it or you can read about it on the Oracle Blog. In that post there's a video of Martin and I smiling because the jury just told us we won :-)

Here's a video where you can see what we build:



I didn't really want to talk about the developer challenge in this post, but more on how you can integrate the Oracle Social Network with APEX. So lets concentrate on that now...

The Oracle Social Network is still in beta and we got only access to it during OOW (and a couple of days after to make the video). During the challenge we used the PL/SQL API which was part of the documentation (edit: I'm unsure what we got will be part of the production release, as it was Noel Portugal who build that example for the challenge. Thanks Noel!). As we have some great web service API's in APEX I immediately thought to try to use those. Unfortunately during the challenge we didn't have enough time to get things working, but straight after I discussed with Jason Straub and after he told me I didn't need to specifically set the complete headers, it was working great (Thanks Jason!).

Below I try to explain the most important parts of the code.


To integrate with OSN you can use RESTfull webservices. The OSN documentation is a great resource and the calls are well documented.
Line 119 shows the url you need to do to post a new message. You post a message to a conversation. In the full package you can see how to create a conversation too.
Line 120 shows what you have to post, basically a json string with the message.
Line 121 shows the REST request; you call a url, and do a post with in the body the json string. As everything is going over https you have to have your Oracle wallet configured with the certificate.

If you look at the complete osn_pkg package, the submit_osn procedure is the call we do in the video. As OSN is secured you first have to connect with a username and password. You get back a cookie and random id and you have to set that in the header of all the next calls.
By using the apex_web_service package you only need to set the headers once. Next in the procedure we create a new conversation, we add more members to it so others can participate in the conversation. In the conversation we add a message and a document (screenshot) if there's one.

I made the package open source on GitHub, so you can see the complete package there and you can quickly integrate with OSN from APEX. The only thing I want to ask is, if you improve it or integrate other parts of the Oracle Social Network once it launches, give your code back as well so we can use this project as a great source for the OSN and APEX community.

Hope you like it...

Monday, October 15, 2012

Reading Oracle (APEX) docs on iPad

With the new release of APEX (or Oracle in general) it's always useful to re-read the documentation again, even if it's just the release notes and the installation guide...

I use my iPad a lot to read articles and books, especially when I'm offline it's very useful.

You can go to the site and read the documentation in HTML or download the PDF, but you can also download the documentation in ePub format (for examples the release notes of APEX 4.2).
When you click on the HTML link, the ePub link will appear for that document.


I find the ePub format useful as I can read offline and set some bookmarks for certain pages.

Hope you like this quick tip!

Changing to Responsive Theme in APEX 4.2

If you read my previous post about APEX 4.2 being in production you know I really like Responsive web design.

So what does it take to change your current theme to a responsive theme in APEX 4.2?

The first thing you have to do is create a new theme based on "Theme 25: Blue Responsive". Go to Shared Components > Themes and follow the wizard to create a new (Desktop) theme from the repository.


Once you created the new theme you need to follow the wizard to switch your themes.


Note that if you customised your current theme to include for example some custom JQuery libraries or your own css files, those won't be included in the new theme. You can always add that later. 

But once you switched your theme, that is about it... you have now a responsive theme and your app is using it... but here's the catch... it might not use it yet to the full extend and it might not respond as you would like it to do. The reason is your regions and page items are now making use of the new Grid Layout, but the wizard did only as good as it could, so you need to verify every page yourself and see if it looks like you want.

Let's take the example of the Feedback Page in an old Sample Database Application I had in my workspace. After I switched the theme the page looked like this:


Not really nice heh?  The display only text is shifting down and the icons are not next to the items, instead they are underneath. Also the buttons seem a bit small in this design.

Here's the backend of the page:


You see P102_A, P102_X and P102_Y? Those are Start Stop Table item types, to align items and buttons nicer...

Note that in APEX 4.2 that item got renamed to Stop and Start Grid Layout and it is even deprecated now... and that makes perfectly sense, table based layout is passé, welcome to div and css or even better HTML5 and CSS3! 


So first thing I would do is just get rid of those items.

The next big thing is how the items are set on the grid. The wizard moved the items on Column Span 1 (so it starts on Row 1 and it takes only the first column of the grid, in total there are 12 columns in the grid). It looks like one column span is a bit small for our content, so either you make that bigger, or you put Column Span to Automatic so APEX itself figures out what to do, which I would recommend (to start with at least).


If you have many items and you don't want to go into every item separately you can right click in the tree view and "Edit All" page items at once. You need to remove the one in Column Span for every item, that will set it to Automatic.


To make our Feedback page a bit nicer, change the region template to "Alert Region".
Edit the buttons and chose the Large Button (Hot) as the template.
Run your feedback page again and this is the result:


I know which one I prefer :-)

Sunday, October 14, 2012

Oracle Application Express (APEX) 4.2 production

A few hours ago Oracle made APEX 4.2 available for download.

If it's the first time you look at 4.2, you can read about the many new features. With every release I have to say the same thing... it's the best release ever :-)

Obviously mobile is a big topic in 4.2, but for me personally I like the integration of HTML5 and CSS3 the most. At OOW, OTN asked me about APEX 4.2 and what I liked... there are so many, but the support for Responsive web design is the "key feature" for me to create future applications in a declarative way. That interview was even done before Shakeeb's excellent presentation about Responsive Web Design and his nice video.



Next to release, the APEX Development team updated apex.oracle.com with a fresh new look and feel! It looks very similar to the Oracle Cloud now. I like it very much.


So go and download 4.2 and start playing with it in your own environment today!

Saturday, October 13, 2012

Oracle Database Cloud active now

A few minutes ago I received the official mail that my new Oracle Database Cloud was ready to be activated.


Once I clicked the link I got to the screen to Activate the Service.


Clicked on that button and I got a new mail my account was ready... and yes we are up-and-running in the Oracle Database Cloud.


Well done Oracle :-)

Monday, October 08, 2012

Oracle Database Cloud (and APEX)

During last Oracle Open World (OOW) the general availability of the Oracle Cloud was announced.

If you want to start to deploy your Oracle Application Express (APEX) applications in the Oracle Cloud you need to subscribe for a Database Service. Here are the steps to do so.

1) Go to cloud.oracle.com and click the Database link.


2) You can subscribe for a 30-day trial service before you need to pay.
Follow the wizard; it will ask for your details (and credit card info, but it won't be charged yet)



3) Once you enter all your details, you get the confirmation of your request

4) You will also get an e-mail that confirms your trial request has been received, but that you need to wait for the activation e-mail.

5) You can already login into your dashboard at cloud.oracle.com to get an overview of your services and trial requests.


It's a week ago I subscribed for the service, but so far I didn't get an activation email yet.

I was part of the beta-group the previous months to test out the database service (fully functional). Compared to that beta, the look and feel changed of the dashboard. In order what to expect once the service is activated: the APEX version in the Database Cloud is APEX 4.1.1c, a special edition of APEX 4.1.1. The closest you can get to that release yourself in your environment (on premise) is installing APEX 4.1.1 and apply the patch that comes with the Oracle Application Express APEX Listener 2.0 (EA2). That will enabled for example Restfull Webservices.
In the Database Cloud you will also see the packaged applications, like you have in APEX 4.2 (as you can see on apex.oracle.com at the moment).

Once the Trial license expires you will need to pay for it... here are the prices as they currently stand:


You might think that it looks expensive, but I think for the S5 it's competitive to alternatives if you start to compare what you get.

The Oracle Cloud is running on Exadata (but with resource management), is fully backed-up, has an active data guard (standby) and includes the Oracle license and support. It also is fully installed (APEX, APEX Listener etc.)
To setup such a system yourself in for example the Amazon cloud (EC2 + S3), you are looking at a high cost too, and you are responsible to keep it online. The virtual machine is the responsibility of Amazon, but you need to look at the database, APEX and the webserver yourself. 

I would probably go with a combination: the Oracle Cloud for production applications (if possible - see the catch further up), but keep our Amazon servers at least for development (as you probably need more than one schema).

During my beta testing there was one catch... some database functionalities are turned off (for now) e.g. Locator, Spatial and outgoing network services straight from the database. That basically means that for    many applications we can't use the cloud just yet as we use locator intensively and send out mails from the database too. It also remains to be seen how fast Oracle will upgrade the Oracle Cloud to APEX 4.2 once that is production.

Oracle has also many other cloud services, one in particular I would be interested in: the Oracle Social Network! I had the chance to play with it (and integrate in APEX) during OOW, but I'll talk more about that in another blog post.