The Movember Ashes Curse and PL/SQL Parameters

A wise man once said that those who fail to learn the lessons of history are doomed to repeat them.
Time for a quick history lesson…
England’s recent supremacy in Ashes contests have a commmon theme running through them. In none of the last three series has any Australian fast bowler sport any facial hair.
The bristling tache has been a feature of potent Australian attacks since time immemorial.
From Frederick “The Demon” Spofforth sporting the face furniture that inspired an England batting collapse which gave birth to the Ashes legend, through Dennis Lillee and (occasionally) Jeff Thompson, the tache reigned supreme.
Having reached an exuberant zenith whilst working with Merv Hughes, the tache took a lower profile for a time as the top-half of Jason Gillespie’s beard.
There was a time during the 80’s when England seemed to have cottoned on to the power of the tache and managed to fight fire with fire with notable contributions evident on the upper lips of Botham, Gooch and Lamb.
More recently however, the moustache’s mystic ability to make an English batting line-up do a passable impression of a deck-chair seemed to have been lost in the mists of time.
Then along came Mitchell Johnson’s Movember Mush Mantle.
Johnson himself has quite a respectable test record, but it seems that he may have re-discovered the secret power of the mighty moustache.
As we’ve got a couple of weeks before the second test begins, the moustache has a bit of time on it’s handlebars so has kindly agreed to illustrate the fun and games to be had with assigning default values to PL/SQL parameters.
Continue reading

Going Green with the Oracle Recyclebin

I’ve been seeing rather a lot of Chris Hemsworth lately…in more ways than one.
My most recent trip to the local Cinema saw him reprising the role of Thor, or “Phwoarrr !” as Deb insists on calling him.
No spoilers, but let’s just say that the scene with the topless blonde was not all I’d hoped for.
Not that I feel the need to compete but, like Chris, I can also do my bit to save the planet, courtesy of a bit of recycling.

Once upon a time, when you issued a DROP TABLE command, the table, together with it’s associated indexes and triggers, was wiped from the face of your database, as if it had never existed.
Of course, if you subsequently decided that you shouldn’t have dropped the table, your options were limited to re-creating it (and the data, indexes etc) by hand, or going through the fun and frolics of a point-in-time recovery.
Since 10g however, things have been a bit different. Continue reading

Generating an md5sum on Oracle Database LOBs – or how to organise your Holiday Snaps

Following the trend in these straightened times, Deb and I decided to stay at home this year rather than going away on holiday.
I say “decided”, but this was really more due to the fact we were terribly grown up and bought a house last year.
As a result, the only recreation we could afford was a walk around the garden…whilst pushing a lawn-mower.
In an attempt to recall happier times, I’ve had a look back of some of the photos from our last proper holiday, in Canada.
As well as providing some happy memories, this also gives me the opportunity to explore how to compare an operating system file ( such as a jpeg) with a LOB held in the database.
Continue reading

How Oracle uses Space, sort of.

Space. The Final Frontier.
My long-suffering Mrs does enjoy a bit of sci-fi especially if some hunky all-action type is wandering around with his shirt off.
“That man has such a nice personality”, she may well sigh, staring dreamily at the screen.

As with any software Oracle error messages can look as if they’ve been put together in some alien language.
This is especially true if your fairly new to Oracle.
When you get space errors in Oracle, the answer is not necessarily to simply add more space.

What we’re going to look at here is :

  • what a tablespace is and the various things they are used for
  • how redo logs work ( and how they are archived)
  • some of the space related errors you may encounter and what the underlying causes may be

Of necessity, I’ve made some generalisations here. The purpose of this post is not to provide an in-depth technical guide to the inner workings of Oracle. Rather it is to provide enough information for you to work out whether you should be looking up the phone number for your hard-pressed DBA, or looking at that bit of code you’ve just run.

Also, like the author, this post is a bit short of cache. For the sake of simplicity (and that weak pun), I’m going to pretend that Oracle uses memory in one amorphous lump.
Additionally, I’ve not taken into consideration Direct Path Inserts.

Continue reading

Re-structuring data for Hierarchical Queries – or (Tree) Walking With Big Macs

Steve McNulty. Even the name sounds a bit hard. This is not the hero in Jason Statham’s latest celluloid exploit. Neither is it the central character in a hard-bitten cop drama.
Steve McNulty is, in fact the current Luton Town captain and a member of an endangered species – the stopper Centre-Half.
When you first set eyes on him, he looks, well, a bit chunky. You might imagine his nickname to be “Big Mac” because of his penchant for a certain fast-food chain.
This is something of a mis-conception.
Firstly, he’s not overweight. In contrast to the other players on the pitch, his body has not so much been honed to athletic perfection as hewn from solid rock.
It is a build that has not been seen for years in the elite (effete ?) Premier League.
He’s not the fastest player, as you’d expect, but he’s strong in the tackle. When he heads the ball, adjectives such as cushioning and glancing do not apply. It’s a Kirby Kiss (he’s a Scouser). The ball is definitely not his friend.
So, Big Mac he is not. He couldn’t be associated with anything that’s served with namby-pamby french-fries. A McNulty burger is a huge slab of meat wedged between two halves of a cottage loaf. It would only ever be served with chunky chips.
It’s McNulty and friends that provide the inspiration for the examples that follow.
I recently came across a situation where I needed to take some relational data and convert it into a hierarchy for the purposes of dropping it into an APEX tree. This proved slightly more challenging than I originally thought. Continue reading

Native Dynamic SQL – Dodgy Code and DRS

Dynamic. That’s a positive word if ever there was one. Ascribing this adjective to anything would convey an image of energy and forward momentum.
On the question of Dynamic SQL, the images are rather more equivocal.
On the plus side, Native Dynamic SQL gives you the ability to :

  • execute DDL statements from within PL/SQL programs
  • code for instances where the required DML statement is not known ahead of time

On the flip side, it can also mean code that is:

  • difficult to read and maintain
  • prone to performance problems
  • insecure

To wander through this minefield, I have enlisted the support of a world where DRS does not stand for Dodgy Review System.
Yes, it’s the wacky and entertaining (not always intentionally so) world of Formula 1… Continue reading