Old Dog, New Phone – Insert into multiple tables in a single statement

I got a new ( and possibly new-fangled) phone recently.
Having spent a suitably geeky amount of time exploring the new features of this slab of Android lovliness I did come across something which left me quite stumped… somebody rang me up on it.
Increasingly frantic tapping of the little green phone icon failed to result in me answering the call.
It was at this point that Deb took pity and explained in that ever-so-patient way people use to the hard of thinking, that I simply needed to swipe.
Needless to say, she’s not ever mentioned the incident again and would never dream of taking any opportunity to bring it up to elicit a laugh at my expense. Ahem.
It’s unfortunate that I also got a work phone recently and spent five minutes tapping the screen before I worked out that the Blackberry I was holding was not, in fact, a touch-screen device.
As the fast-paced world of consumer electronics passes by in an ever-increasing blur, I’m comforted by the fact that I can still learn something new.
For example, I was recently faced with a situation requiring me to load data from one table into two further tables, depending on certain criteria.
With the aid of my trusty netbook ( a form-factor that is apparently as outdated as it’s owner), I shall now demonstrate the wonder of the age that is the multi-table insert statement.
Continue reading

An APEX Database Monitoring App for XE – Guilty GUI pleasures

Guilty pleasures. For some, it’s a “diet” burger with “diet” fries, washed down with a “diet” shake. Others have a penchant for Kurt Geiger shoes. “I’m Welsh and I’m worth it”, they may well say. It may even be that Def Leppard track nestled in your playlist between Coldplay and Oasis.

In programming terms, APEX seems to fall into this category for me. On the one hand, it’s a declarative development environment. This means that, unless you’re very careful, the application you write for it is not going to be too portable to other front-end technologies. But, oh, it’s so nice to be able to bang out a bit of SQL and/or PL/SQL, click my mouse in the right place, and have a nice GUI application drop onto my browser.

If you’ve decided to try the latest and greatest APEX version on your XE installation, you’ll notice that the default Database Welcome Page disappears after the upgrade.
Rather than hunting around for it, I’ve decided to knock up something a bit better…well, different.
So, if you’d like to know how to get some interesting configuration information out of the database…or just want the entertainment value of watching me blunder about in APEX then read on… Continue reading

ORA-02030 and invisible objects. The database bites back !

Being Luis Suarez’s agent must be an interesting job right now.
Maybe the man was a bit peckish.
Alternatively, maybe he’s resigned to the FA’s reluctance to introduce a mid-season break and was simply making his own arrangements for time off during the season.
Either way, this particular agent may well be trying to sign Luis up for an ad campaign for a popular brand of toothpaste.

Oracle DBA’s may sometimes have some sympathy with Suarez, although they’re more likely to end up chewing the desk in frustration, rather than their fellow DBA’s (unless the Christmas Party has really gotten out of hand).
Every so often, Oracle throws out an error that, on the face of it, makes absolutely no sense…
Continue reading

How long is a (piece of) String. Cricketing Greats and the length function

My Dad gave me a book recently – the 100 Greatest Cricketers. As well as selecting what – in his opinion at least – were the 100 finest exponents of the game, the author also decided to rank them in order from 1 to 100.
At this point, for those who don’t know, I should perhaps explain that Cricket is one of those games given by the English to the rest of the world….to prove what sporting losers the English could be.
For any Australians reading, to whom this statement may ring hollow given their teams current travails, fret not. Historically, England’s brief ascendancy the battle for the Ashes tends to come to a juddering halt when least expected, usually in the form of a 4-0 thrashing ( think 1958-59, 1989).

Anyway, back to the book. Comparing players across different eras is hard enough – just how would you evaluate the relative merits of Sachin Tendulkar and Sir Jack Hobbs, for example ?
But comparing the relative merits of a batsmen and bowler who were contemporaries in the same team is equally problematic. Who is the greater cricketer out of Dennis Lillee and Greg Chappell, or Malcolm Marshall and Viv Richards ?

All of this brings to mind the saying, “how long is a piece of string”.
In SQL, at least, we do have an answer to this question…or do we ? Continue reading

Disabling the Oracle Diagnostic and Tuning Pack APIs – If you want something done, do it yourself

At last, we have reached the final episode of the Star Wars themed odyssey through the tangled web that is Oracle’s Diagnostic and Tuning Pack licensing.
Just as well really, Deb has flatly refused to give over any more evenings to my “research” – i.e. re-watching all of the films. Even the appeal of Ewan MacGregor’s Alec Guiness impression has now waned.
Just to recap then, so far I’ve looked at :

Now, finally we’re going to have a look at how we can minimize the chances of an errant select statement causing a whole heap of trouble.
Yes, we’re going to have a go at disabling access to the Diagnostic and Tuning Pack APIs without (hopefully), breaking anything.
Continue reading

Oracle Database Diagnostic and Tuning Packs – exactly what are you not licensed for ?

It’s that time of year. The expense of Christmas is becoming apparent and January payday has seemed to be forever in arriving.
“…and I need a crown !”, said Deb.
This caused me to pause for a moment. Was my better half getting delusions of granduer ?
Further, delicate enquiries revealed that it was merely a dental crown to which she was referring.
Not that it seems to make much difference financially. You could probably buy a fairly substantial piece of regal headgear for what the dentist was asking.

On the plus side, Queen Deb’s costume for the next instalment of the Licensing Epic doesn’t require such accoutriments…although a big pair of headphones and lots of hairspray may be in order. Yes, I’m still on my Star Wars themed odyssey through Oracle Database Licensing.

In the previous posts, I’ve already covered :

Now, it’s time to get to grips with the licensing minefield that are the Diagnostic and Tuning Packs.
Queue the orchestra….

Episode 2 – Attack of the Diagnostic and Tuning Packs

Confusion is rife in the Data Centre. The Geeki have found that the incredibly useful AWR and ASH utilities are in fact secret members of The Diagnostic Pack.
Fearing the presence of the Dark Side, they must now re-enter the realms of the mysterious Oracle Database License to

  • Determine which features are part of these packs
  • Work out exactly what constitutes usage of these packs
  • find out which database objects that are part of these packs

With this information, at least they will know which objects they must avoid if they are not to have to pay substanital additonal licenses…

Disclaimer

This code has been written and tested on Oracle Database 11gR2 Express Edition.
The licensing information I’ve referenced is for Oracle Database 11gR2.
I’m fairly sure it all works as expected. However, as you undoubtedly know, you shouldn’t take my word for it.
Before you go playing around with this on any production environment, please make sure it does what I think it does.
Of course, if you do find any issues, I’d be great if you could put a comment on here so that I can correct any issues…and also to give a pointer to anyone else looking at this post.
Yes, I know the standard disclaimer about “similarity to events or persons living or dead” always goes at the end of the film, but I thought it best to put it at the start.
Incidentally, have you ever wondered exactly what real-life events Star Wars could have a similarity to ?

Continue reading