Saturday, November 29, 2008

APEX Meetup @ UKOUG on Monday

Next week the UKOUG conference is going on. I'm flying to Birmingham on Monday and will stay till Thursday. I believe UKOUG is one of the biggest Oracle conferences in Europe. It's a pity it's the same time as DOAG, but that is mostly towards the German speaking people. 

There are also some APEX presentations at UKOUG:

What’s Hot and What’s Not – an Overview of Oracle Development ToolsMr Sten Vesterli01/12/2008 11:00 - 12:00 Track Track 5
Oracle Application Express Now and in the FutureMr David Peake01/12/2008 13:10 - 14:10 Track Track 6
Application Express Best PracticesMr John Scott02/12/2008 11:05 - 11:50 Track Track 4
"Tools: APEX, JDEV, Forms, SQL DEV - the choice is yours"Mr Grant Ronald02/12/2008 13:15 - 14:00 Track Roundtables
A Delicious Blend of BI Publisher and Application Express Bursting with Flavour!Mr Nathan Morgan03/12/2008 11:45 - 12:30 Track Track 8
Mastering charts in Oracle Application Express (APEX)Mr Dimitri Gielis04/12/2008 09:25 - 10:10 Track Track 5
(Re)Developing a logistic application in APEX in the real worldMr Roel Hartman04/12/2008 15:05 - 15:50 Track Track 5
Securing an APEX application on a Microsoft platformMr Andy Ogg04/12/2008 16:25 - 17:10 Track Track 5

As you can see I'll talk about charts in Oracle Application Express on Thursday. I'll start to explain how you can create charts in APEX and make them prettier and what is happening under the hood. I'll discuss there are different versions of charts in APEX (based on Anychart 3.3 and 4.1) and at the end I'll also try to quickly show the apex migration kit to Anychart 5.

In the APEX Forum we also talked about having an APEX Meetup on Monday after the opening party (20.30h). We'll probably meet at the entrance of the opening party or you can follow David Peake, John Scott, Anthony Rayner, myself or some others to the "APEX heaven".

See you in  a few days!

Friday, November 21, 2008

Group Headings in an Interactive Report (APEX)

Did you ever wanted a group heading above your column headings in an Interactive Report in APEX? I wondered why that wasn't already included in APEX, as all components are there to get it to work. Let's create a little example to show what I mean.

Create an Interactive Report on the emp table (for ex. select * from emp).

In your Interactive Report details there's a section Column Groups where you can define groups.
But it also says: "Column Groups are used to group columns together on the single row view."
In my example I created two groups.


Next we need to edit the group to say which columns belong to which group.
In my example I specified that the columns Empno and Ename belong to Group 1. I specified some other columns for my Group 2.


If you run the page you'll see this IR (without group headings)


But when you select the single row view (the Edit icon in front of the row) you'll see this:


So you can see the groups nicely in the single row view but it's not there in the normal report...

So I thought, as APEX is completely dictionary driven, we should be able to find all the pieces and with some javascript we should be able to change the DOM element to include the group headings in the normal report too. The result:

You can see this example live here, the source code is also there, so you can see how I did things.

On the page I open the "Select Columns" automatically, so you can see the available columns and the groups in () and you can dynamically play with showing and hiding columns.

In short the way it works:
1) Query the APEX dictionary to see which columns and groups there are defined and return a string that can be parsed into a json object.
2) Create a javascript function to add the group headings above the column headers. I put some notes in the javascript and added a lot of console.log's. If you remove the // you'll see in Firebug a full trace what is happening.
3) To attach it to the Interactive Report and call it from your page you need to do some more. At OOW I had a chat with Carl about it, at the moment you can't call your own function at the end when the interactive report is called (but he was going to change that in future releases). Carl told me I was forced to put a little timeout there to make sure the Interactive Report was drawn before my javascript ran.

Feel free to try it in your own environment and give some feedback. The code is generic so you should be able to plug it into your environment without that much effort. I didn't use jquery as I wanted a generic solution for a "normal" APEX environment. Another thing I didn't do is looking if you defined a link (edit icon) before the row or not. So these might be enhancements for the next release...

Wednesday, November 19, 2008

Flashback table data prevented by a constraint

When I was reorganizing some tables I deleted some data which at the end I wanted to reuse.
I was pretty confident that with the flashback technology in the Oracle database I could get my data again. So I was surprised when I got the message "ORA-01466: unable to read data - table definition has changed".


I thought I had done something wrong so I build a small test case to see what was happening.

-- Create table with one record
create table t (b varchar2(100));
insert into t values ('hello world - works');
commit;
-- Look at the data
select * from t;
-- What timestamp did I still see my data -19-NOV-08 02.09.23.478019000 PM +00:00
SELECT SYSTIMESTAMP FROM dual;
-- Create an index
create index t_idx on t (b);
-- Delete all the data from my table and commit
delete from t;
commit;
-- There's no data anymore, nice
select * from t;
-- And with the flashback technology I see my data
select * from t as of timestamp to_timestamp('19-NOV-08 02.09.23.478 PM');
-- Insert another record
insert into t values ('hello world - no go');
commit;
-- Do some DDL on the table now, add a constraint
alter table t add constraint t_pk primary key (b)
select * from t;
-- I still see my data at this stage, but now we drop the constraint and delete the records
alter table t drop constraint t_pk;
delete from t;
commit;
-- Use flashback again
select * from t as of timestamp to_timestamp('19-NOV-08 02.09.23.478 PM');
-- I can't get to my data anymore

When reading through the documentation this made it clear: "Oracle Database cannot restore a table to an earlier state across any DDL operations that change the structure of the table".

Oracle does have limits ;-) and time for me to read through the documentation again...

Tuesday, November 18, 2008

Anychart 5 integration kit for APEX

A few days ago we released our Anychart 5 integration kit for Oracle Application Express (APEX).

Background

APEX has the ability to create (flash) charts. They are based on an older version of Anychart, version 3.3. Although these charts are already nice, there are some problems with it. You can't do everything you want with it, you can't print for ex, in short they look fine but not great.
Anychart released a while ago Anychart 5 which not only looks a lot nicer, but it resolved the problems and it has a lot more possibilities and features! Below, on the left, a chart created in APEX by using one of the predefined examples and on the right, the chart in Anychart 5 format.

I hope the charts speak for themselves ;-)

Installation

You can install this integration kit in a couple of different ways. If you prefer to keep the original APEX installation intact, you can do that and copy the integration kit in another folder. That means you can use the Anychart 3.3 and Anychart 5 charts together (like on the site of us).
You can also overwrite the files that came with APEX (take a backup first!) and that should change all your charts (also existing ones) in Anychart 5 format.

In both cases you can still use the wizards in APEX to create the charts, but if you decided to not overwrite the files, you need to make a small change in the chart region to point to the right path where you installed your files. The integration kit was tested on APEX 3.x (0, 1) and database 10g, 11g and XE with both the http server and the Embedded PLSQL Gateway. However if you do find a problem, please let us now or write a mail to apex@anychart.com.

Under the hood

So what's happening? The Anychart 5 file format is in a very different format, so what we did is creating a translation file which converts the Anychart 3 xml into Anychart 5 xml. You'll see the 2DColumn.swf of the integration chart are really small, that's because only the translation is done there and then sent to the anychart.swf file in the format it recognizes.


Using the integration kit

You can keep using the wizards in APEX to create your chart. This integration kit is meant as a first step towards the full kit we are working on. All the current types of charts in APEX are already supported by this kit and more, like for ex the combined charts - like on the screenshot above-, but Anychart 5 can do a lot more. For the Dashboards and Gauges for ex, which are currently not yet a type in APEX, you would need to write some more code yourself.
The followup kit will also provide you with the possibility to create these types of charts (Dashboards, Gauges, Maps, Gantts) through a wizard or at least with writing as less code as possible. In the meanwhile we (Apex Evangelists) can provide you with consulting to create other types of charts.


Examples

A full set of examples can be found on this site. All types of charts are shown in the standard APEX format (without changing or making it nicer), in the middle (if you enable the checkbox) you'll find the exact same chart but using the integration kit (so no changes made there) and on the right you find the same chart but with a few changes that shows the potential of Anychart 5.
You can also view the source of the region, the chart and the series that are used.

Purchase

The integration kit comes with a trial version of the Anychart 5 .swf file. You can see it by the watermark. If you buy the full version from the Anychart website and replace the anychart.swf file that comes with the integration kit, the watermark will disappear.
The integration kit itself doesn't cost you any money, you only need to pay for the Anychart license. APEX users get a 15% discount by using the code: APEX15

Final thoughts

This integration kit came together by the partnership of Apex Evangelists and Anychart. I would like to thank the people at Anychart for their help in working on this.

Friday, November 14, 2008

My first live hockey game

On Tuesday I went to my first ever live hockey game. I didn't know what to expect when James said me he had tickets for the hockey game, but he told me hockey is pretty big in Canada.

I saw the game Calgary Flames against Toronto Maple Leafs, which Calgary won 4-3. They played for a full house, so the atmosphere was very nice. The Flames first got a goal against, but it didn't take long before they scored some nice goals and took the lead. During the game you get sometimes time-out for commercials, that was new for me (well all of this was new for me).

I must say I liked it very much! Hockey is such a fast game and there's always a certain tension in the air. Like for ex the last minute when it was 4-3 the Leafs played without goalie!

Seeing hockey live is so much more fun than watching it on tv.

Players on the field, big screen tv's to watch the replays, real flames when goals were scored... everything for a fantastic evening.

Tuesday, November 11, 2008

Damn, APEX Page deleted! What now?

You know that feeling when you're working hard on a system, did a lot of changes, finally get the required result and start clean up old code?

I was in that stage... but then it went wrong: I deleted the wrong components and even some pages...

So what do you do then? What would you do in a not-APEX development environment? Getting an old file back, but what if you changed multiple files? Go back into source control and get the latest release? But are you using source control?

I was lucky as in APEX I could just Export my application as a few minutes ago. The below screen shows this feature to you.


Your database needs to have Flashback enabled for this, but who's database is not running in archivelog mode and has the flash recovery area enabled?

Maybe some of you didn't know about this possibility, it's definitely a nice one.

Sunday, November 09, 2008

First time in Canada

I just arrived in Calgary where I'll have some meetings (around the use of APEX).

It's my first time in Canada. I didn't know what to expect, although I got slightly worried when I read a (bad) review about the hotel I'm staying in. But to be fair, the Ramada hotel isn't that bad. The room is nice, but the hotel is a bit dead.


It's a bit too cold for me in Calgary (only 2 degrees), but I guess I can be lucky as the taxi-driver told me it can be -40 degrees over here! I didn't see much else yet, only 17 Avenue where I went to a famous bar/restaurant called Jack's.

Tuesday, November 04, 2008

APEX Views are so useful

Oracle Application Express is getting more and more popular. A lot of people started to use it, even by some who are no real developers. They use APEX because it's helping them to do their "real job". And as with a lot of these "at-the-side" applications, the app becomes bigger and other people are starting to use it. Of course they are lucky as APEX can scale very well, but being a non-developer they hit at a certain time the limits or their technical capabilities and interest to make it an enterprise application.

On one of our projects we have to rebuild such an existing APEX application. There are a lot of pages in the application. In the requirements document there are screenshots of regions which need to be available in the new system. As you can imagine it can take a while to find a certain region.

Luckily, APEX is repository based, so all information of the application you find in a table. To make life easier, the APEX development team created APEX views on top of the APEX tables. You can compare it with the Oracle database itself where you have views on top of the x$ tables.

If you go to the Utilities tab in APEX, you'll see the APEX Views button (see screenshot above). If you click on that you'll get a nice screen with all the APEX views. You can also search for a view, for ex. I searched to get all APEX views that contain 'region'.

If you click on for ex the APEX Application Page Regions icon, you get all the details of the view and you can query it from there. You'll see the columns with explanation:


You have the possibility to select which columns you want to see when you run the query, which where clause you want to add and the query that will be run when you hit the go button.

It saved me a lot of time to find the regions I had to search for. A repository based system like APEX has so many advantages...