Friday, 17 October 2014

PL/SQL Challenge Roundtable

Do you write PL/SQL? Me too!

Trouble is, sometimes it's hard to decide how to structure your packages - particularly in an APEX project. Over at the PL/SQL Challenge website run by Steven Feuerstein and friends there is a page dedicated to roundtable discussions.

I submitted my question not so long ago and hope to get some interesting responses. Why don't you give the site a visit and contribute? The discussions usually last for about a month.

Past discussions are available to view - last time Steven asked for use cases for DBMS_RANDOM. You could even test out your PL/SQL while you're there and take a few quizzes.

Wednesday, 8 October 2014

The moon is a sphere

I was fairly excited at the prospect of seeing tonight's lunar eclipse but I neglected to take into account not being able to see the eastern horizon from my house.

I missed most of the total but enjoyed the crescent of the partial eclipse re-emerging. It's amazing how distinct the shadow leading to the penumbra.

My friend said there will be some good shots in tomorrow's paper. I laughed and said here in the 21st century I could probably get a high res online right now that matched the view I had through my binoculars, with the moon sitting on a bed of a few dozen stars.

A Twitter search for #lunareclipse gave me this gem from Australian based astronomer Katie Mack.
Not quite hi-res, but certainly true to the view I had. Bring on the next of the tetrad.

My friend also suggested I could listen to update on the wireless, then I wondered at how the utilisation of radio waves were so revolutionary - being able to transmit signals with no telegraph poles.

I wondered what bit of kit we have today that our grandchildren will snigger at - and I figure it's probably smartphones.

"What do you mean we can't send signals by thought?"

Katie posted a few other great snippets, just as Neil Tyson often does with physics. I'll leave you to ponder this gem

Wednesday, 1 October 2014

APEX 5 not so near

It seems I may have jumped the gun a little.
Idioms - the bane of ESL speakers?

Reading Anton's comment on a Friday afternoon got me a little too excited - upon reading it again Tuesday (we had a long weekend) I realised it was tongue in cheek.

So instead I went to Twitter to find what's being said at Oracle Open World about #orclapex. Turns out there will be a third early adopter - a feeling I got from something I read back in March.

There will also be a beta program for the first time - details to come since so far the only source of this information so far (for those not at OOW) is Twitter.

Who needs reporters anymore when you have real time feeds & photos from actual events? ;p

Friday, 26 September 2014

APEX 5 imminent?

It seems the release of APEX 5 is due within hours - just in time for OOW weekend.

To quote Anton here
Apex 5.0 is going to be released in a couple of hours
It's a long weekend here in Perth, and I have a footy grand final to watch - but no doubt I'll be installing it somewhere soon!

All that being said, apex.oracle.com is still on 4.2.5, so don't hold your breath for too long.

Stay tuned...

Monday, 22 September 2014

Leisure Suit Larry Ellison

Larry Ellison 1978
So at 70 years of age, the man who's been heading Oracle since before I was born is stepping down.

While I admit I'm far removed from the reality of the situation, I find it a little amusing how it's been deemed as a 'shake up' when a few paragraphs before he's quoted as saying this (referring to new co-CEOs)
“I am going to continue to do what I have been doing the past several years and they are going to continue doing what they have been doing the past several years,” 

So I bet he's probably going to be working in the same office, just the title under his name on the door will read "CTO". So for us at the coal face, surely this means he will spend more time directing the nature of the beast and leave operations to those who specialise. That sounds to me like a good thing.

I enjoyed this New York Times article, but writer Quentin Hardy made me read one of the last paragraphs a few times
Mr. Ellison does not leave his company entirely untroubled. Besides continuing challenges in cloud computing, including acquisitions and new competition, the company faces a raft of new types of databases, first developed inside Google and Yahoo, that also threaten the dominance of the relational database.

I've been thinking recently what the next generation of databases will be like. The relational model was revolutionary at the time, but bigger data and intelligent networking will surely one day reach another punctuated equilibrium. No doubt it will come from somewhere like contemporary giant Google.

If I was a passionate billionare I think I would have left the business behind long ago, along with the suit.
Circa 1993 - no eyebrows then either

Monday, 8 September 2014

Using Post-Authentication to run process after APEX login

A frequent requirement, and hence frequent question on the forums is
How do I run procedure x after the user has logged in?
This is often required for such tasks as determining user access, such as populating a restricted Application Item relating to a role like F_IS_ADMIN based on the username defined in substitition string APP_USER

Those new to APEX and unfamiliar with certain concepts may consider using an Application Computation, firing "On New Instance (new session)"
Application Computation Frequency

It sounds fair enough, and I remember doing the same thing when I was first learning APEX. The documentation on understanding page computations states
The computation point On New Instance executes the computation when a new session (or instance) is generated
This still isn't clear, but this actually fires when you first navigate to a page in your application - any page. This means when you first open a page like /apex/f?p=100:1, which may redirect you to the login page - the 'on new instance' event has already fired since APEX needed to provide you with a new session to render the home/login page.

In other words, these events can be generally described in the following order:
  • Open home page
    1. On New Instance (new session) - APP_USER is 'nobody'
    2. Redirect to login page
  • User enters username/password and submits
    1. Pre-Authentication 
    2. Validate credentials - APP_USER now set
    3. Post-Authentication
    4. Redirect to relevant page

I think I've only used 'On New Instance' once or twice, possibly to prime content of application items - but I use 'Post-Authentication' all the time to calculate values based on the user who just logged in.

Post-Authentication is defined in the Authentication Scheme, and expects the name of a stored procedure.
Shared Components -> Authentication Scheme
This stored procedure can be defined within the Authentication Scheme -> Source -> PL/SQL code as an anonymous block:
PROCEDURE post_authentication IS
BEGIN
  -- do stuff here

  null;
END 
post_authentication;

For better performance and code management you should place it within a PL/SQL package. That way it doesn't need to be interpreted dynamically every time a user logs in.

The Post-Authentication Procedure Name attribute just needs the name of the stored procedure, no semi-colon.
apx_auth_util.post_authentication

The PL/SQL may run something like:
IF v('APP_USER') = 'WESLEYS' THEN
  apex_util.set_session_state('F_IS_ADMIN','Y');
END IF;
I understand changes are coming in APEX 5 regarding when these events fire as you navigate between applications that share authentication.

This also reminds me of a little experiment I wrote ages ago to determine the order of page/application events.

Friday, 29 August 2014

Birds don't make the best ornithologists

This week I listened to episode 44 of one of my favourite podcasts - Inquiring Minds. It was an interview with David Epstein on the 'science of athletes'.

The podcast culminated with some really interesting points regarding the concept of 'talent' - what it really means, how it can be measured or influenced. One particularly interesting basis was the traditional idea that '10000 hours' training leads excellence in any particular skill, vs what's in the genes.
Exhibit A: Kalenjin (regional Kenya) long distance runners. Well worth the listen to get the full detail.

Another interesting example was a female softball player Jennie Finch that made the news in 2004 striking out professional male players. The men expected to have no problems hitting her out of the park, but players confused their perceived reliance on ability to track ball in flight and rely on 'talented' reaction time with what they actually do.

(Getty Images)
In fact, this article I found when searching for Jennie Finch goes into very similar detail (since it's written by the interviewee!) and suggests
Given the speed of the pitch and the limitations of our physiology, it seems to be a miracle that anybody hits the ball at all.
It's apparent that players interpret the pitcher's shoulder, body rotation, ball thread rotation in flight and other factors to calculate the region the hitter expects the ball to fly by. But since thrown underarm, all information players read to calculate where the ball will land - is lost.
They've even got a bigger, slower ball to hit.

They found likeness to chess, where a good player sees the entire board - a number of moves ahead.
I found likeness to pool/snooker. After the break I might see the next 4-5 balls I can pot in a row. Newer players are often overwhelmed just to work out which one to try.

I'm sure my game would slow right down if was faced with a different shaped table.
Pool tables I wouldn't enjoy
I don't do the topic justice, but I recommend both this particular episode and the podcast in general. I listen to podcast in my commute to work - I play to post my favourites one day, I'd be interested to hear any other recommendations.

The blog post title? A quote from David during the interview