Thursday, February 16, 2017

EECS - Oracle Exadate Express Cloud Service, Step 3

Once you have defined your users for your Express Cloud Service, all users with the role of Database Developer or higher can access the database Service Console. From here all database related actions can be started.
The upper category, Web Access, brings you to the specified part of the APEX builder - more on that in the next post. In the lower category you can create database schema's. For our goal within smart4apex, I created a schema for every developer.
You can define whether the schema should be accessible from within APEX and creating an separate tablespace is optional.
I haven't played around with the Document Store yet, so I have to skip that part. You can also set the password of the administrator of your PDB - the most privileged user within your PDB you have access to. Franck Pachot did an excellent writeup about the privileges of that user. I hoped the "Manage Application Express" would bring me to the "APEX Admin" environment - a.k.a. the "INTERNAL" workspace. But in fact it's a very downsized form of that. 
You can enable Application Archiving (using the Application Archive packaged app), enable or disable workspace-to-schema associations and manage a very small number of workspace preferences.
What I had expected and missing the most here is the option to create multiple workspaces! So one EECS instance means one and only one APEX Workspace! I still haven't found the document that lists that limitation. That was a real surprise for me.

The middle part of the Service Console is the most interesting one for this post. As we would like to access our EECS database like a local one! Assuming you have your favorite tool (SQL Developer, SQL Plus or sqlcl already installed), you have to download the "Client Credentials". On downloading you have to enter a password. You'll need that again to set up the connection using SQL Developer. So fire up a a recent version - I used 4.2 - of SQL Developer and define the connection, using "Cloud PDB" as the Connection Type, point the Configuration File to the downloaded zip file and enter the previous defined password. Make the connection and voila, you are running SQL Developer connecting to a 12.2.0.0.3 database in the cloud! 

And while you can do most of the regular database development stuff, there is quite a list of restrictions, limitations and issues, all listed in this document. So no multimedia, spatial, RAS, to name a few.

Connecting with sqlcl is just as simple. Drop the zip-file in a location easy to find by sqlcl (as you can see in the screenshot above, I dropped it in the sqlcl/bin directory). Fire it up with "sqlcl /nolog" and define the cloud configuration using the zip file:

set cloudconfig /Applications/oracle/sqlcl/bin/client_credentials.zip

As you don't want to type that line each and every time, it's convenient to put that in a login.sql file in the sqlcl directory. 
The zipfile is unzipped in a new directory on your file system - it seems to create a new directory each and every time you issue that command. I hope it gets cleaned up somewhere somehow eventually ...

And is it fast? It feels pretty fast - hey it is an Exadata machine  - , but now and then I noticed some latency in the connection. Not too bad and expected as the server is in the US. I'm sure that will be a lot better once there will be a real European roll-out. In the Service Console there is a little diagnostics tool hidden in the menu in the upper right corner where you can measure your latency. I measured it three times and the latency was around 180ms on average. So that's not super, but not really annoying in a sqlcl / SQL Developer environment. But what would happen if I start clicking around in the APEX Builder?

EECS - Oracle Exadata Express Cloud Service, Step 2

Once you get your services up and running, you can log into your domain - in this screenhot "smart4apex" - on the Oracle Cloud.
Then you'll end up in the "My Services" dashboard. As I have only one, my dashboard looks quite clean, showing just this widget:
Just a few remarks for the designers of this: I am very curious why there is an extra "(Number of ..." in the chart title. The same superflous text is also on another location on that page.
And, more intriguing, what would "0.0323 database instances" mean? 1/0.0323 = 31. So something like days? But February has 28 days...
It would make way more sense to just show here how many instances I had on those day (so, "1" al over the place...).
From this widget you can drill into the "Service Details", where you can set rules and alerts and see the (historical) status of your instance. Funny thing is, I noticed this:

These figures indicate, I have a storage limit of 23Gb. But my service is based on 20Gb. So I get 3Gb "for free"!
Probably that's (more or less) used by Oracle itself (SYS, APEX etc.). So if you buy 20Gb, you really get 20Gb to store your own data!
Now it is time to add some users to this instance. As we - as smart4apex - would like to use it as a development environment, I added all colleagues as a user. 
And i can assign Roles to every user. There is a standard list of roles defined. From the documentation I figured out that the first two are entitled to add or modify other users, but what the privileges and restrictions of the other three are, I still have to discover. What I do know is, if you just assign the "Database User" role to a user, you can log in to the My Services page, but if you try to use the Exadata Express service, you get an "Acces Denied" message. You need at least Database Developer or Database Administrator to access the APEX builder (more about that in a later post).
A nice feature is, you can upload a csv file to create multiple users and assign roles in batch. Saves you a lot of clicks....
And every user you create receives a nice welcome email with a temporary password and a login link. Once you use that link, and login you end up on a (rather outdated - ADF faces built) page of Oracle Identity Self Service to change your password and register three (!) challenge questions. That is a challenge in itself ;-)
Apart from the standard Roles, you can define "Custom Roles" and assign those to users. But any information about how to use these roles in an APEX application is welcome, as I couldn't find any documentation on this subject.

In the next post, I'll go into the database (in)side of the service and in the subsequent one, the APEX development environment of the Exadata Express Cloud Service (EECS).

Monday, February 13, 2017

Intermittent ORA-06502 error when running APEX 5 on 12c

We upgraded our environment from 11.2 to 12c last week. This week we noticed an error in one of our APEX pages, a rather simple form for entering data. Nothing fancy, nothing spectacular - only a spectacular error when you tried to edit a record. 
Running the page in debug mode (even on LEVEL9) wasn't very helpful as you can see below (10 points who immediately spots the error!).
The error didn't occur for all records. It seems that a long(er) Code and Description field on the page resulted in an error more frequently. Also fiddling with a couple of the checkbox fields on the page had an effect.
So I asked Twitter for help. And within a few minutes I got all kinds of tips and advice. But especially one, from Peter Raganitsch was spot on. He suggested, looking at the debug output above, to take a look at the #CLOSE# position in the template. .
My buttons are positioned in that #CLOSE# position, so I took a closer look at those. There were three that passed the Id, Code and Description to other pages as a parameter. So ... the longer the description ... the longer the generated URL would be. And as one of the checkboxes would toggle the availability of one of the buttons, that would also have an effect on the total length of the URL's in that region position. 
So I changed a little code, to pass only the Id's to the other pages (and add a select statement there to (re)fetch the Code and Description. And since then ... it runs as a breeze.

Very weird though this was not on issue on 11.2, but is on 12c....

So what causes this issue, what is the difference?
The answer is: the checksum!

If I create a Report and a Form on DEMO_CUSTOMERS, using the CUSTOMER_ID as the Primary Key, the URL has this checksum on 11.2 : " &cs=3Fqn7QOYkP-TDSLkssvzU7i7QL1E "
On 12c however, the checksum is :" &cs=36Drf3ULxGXswIlT5btBujofcmgwdjJsr-luSfpLjSMpXP71DILliWBz31qkpRJHyPj2RS8iLce5qNkXSSeGbvQ "
And that was probably enough extra length to pass a certain varchar2(<some number here>) in the APEX code that generates the page output....


Thursday, February 09, 2017

First steps using the Oracle Exadata Express Cloud Service

The Oracle Exadata Express Cloud Service was announced at Oracle Open World 2016. This service looks like an excellent use case for Oracle Database development purposes as well as setting up a test environment. And even for small to medium sized production situations it looks very promising as you can see in the table below. Especially the cheapest option offers a lot of bang for your bucks.
But alas, this service was not as widely available as I expected. The first months it was US-only and you could only figure out by ordering the service and then you would find out on the last page that you should "contact your Oracle sales rep". I sincerely doubt whether he or she could provide you with that service, so I just waited until it would be more generally available.
And since a few weeks the Oracle Exadata Express Cloud Service is also available in Europe - I don't know about other parts of the world. A missed chance though that Oracle didn't announce that properly. You can only find out by trial-and-error. And to be clear, your data will still reside on US soil...

After entering my credit card number I made my purchase irreversible and I immediately received an order confirmation. As I expected these cloud things go very fast I started waiting for the mail that would say that my service was ready. Not on that same day. Not on the next day. But two days later, I finally received my "Welcome to Oracle Cloud" email. If any webshop that ships physical items would move that slow, they would be out of business pretty soon. 
But now I was ready to go! First I had to create my "service instance". No clue what Oracle did the last two days, but effectively I only had access to a console where I could create such an instance. Why doesn't Oracle create that instance immediately? Because in the end what I ordered was a service instance - not the option to create one...

Nevertheless, with a few clicks I had requested my instance as seen in the screen below (notice the little missing icons / images on the upper left and right buttons...).
The only thing that had to be done was firing up a 20Gb Pluggable Database (PDB). On my VM that would take a few minutes. So on an Exadata beast ... a minute or maybe two?

Alas, no. For some reason it took 4 (four!) full days. All those days I logged in to see whether there was any progress and all I saw was:
After the Oracle internal issues were solved - the PDB was created super fast, but the registration process failed somewhere - I was finally up and running. 

It took a while, but I hope it was worth waiting for ....