Defaulting Null values in SQL*Loader

Having spent the last couple of months working with a South African ( hello Trevor) and being reminded, oh so gently, of that nation’s recent cricketing success, I was hoping to get the opportunity to return the favour via the medium of Rugby Union.

The Springboks narrow defeat of England in the Autumn International did little to derail this cunning plan. Unfortunately, my emergency backup nationality failed at a crucial moment as the hitherto invincible All Blacks were roundly thrashed by England a week later.
People in glass-houses…

Anyway, what follows is a solution to a fairly specific problem we were confronted with recently.
Continue reading

ORACLE Transactions and Fishing on the Underground

It’s that time of year again. Yes, it is the season to be snotty.
“Man-flu”, was Nurse Debbie’s considered medical opinion. Admittedly, she’s feeling a bit under the weather herself and, as we all know, “Bird-flu” is a far more serious condition.

I think I must have picked up this particular bug during my daily commute, which currently involves quite a lot of time on the Tube.

In order to pass the time in the morning crush that is the Northern Line, I’ve taken on a challenge from Simon.

He claims that, apart from St. John’s Wood, there is no other tube station that does not contain at least one letter from the word “Mackrel”.

Whilst this may seem a somewhat esoteric fact, it’s probably quite appropriate to look for bits of fish whilst wedged into a Tube train like a sardine.

The tube map itself includes station on the Overground Network as well as the DLR so, ironically, this does provide a bit of “wiggle-room” for my Mackrel search.

All of which serves to act as an example in the following exploration of how Oracle transactions work…
Continue reading

Oracle Schema Differences – keeping up with the Prefix Pixie

Saturday 11th September 1976. That was the day that my Dad first took me to see the (occasionally) mighty West Ham United.
The opponents, the rather more often mighty Arsenal.
I still have vivid memories of that game. The noise from the crowd. The fact that the grass looked so green, brighter than on the TV.
West Ham not playing very well. Frank Stapleton putting a bit of a downer on the day by having the temerity to score twice in a 2-0 win for the Gunners.
My Dad recently celebrated his 70th birthday.
His present from his first-born son ? A trip to see the (previously) mighty Luton Town take on the ( probably must have been from time to time) mighty Nuneaton Borough.
Now, this may seem poor reward for my dear old Dad – he takes me to see two of the top teams in the country and he gets the Blue Square Premier League in return.
Additionally, these days it’s less the colour of the grass that assaults the senses than the colour of the boots.
These are various flourescent colours, virtually none of them black.
Mind you, as Deb pointed out, if you play for Luton and spend most of your working life dressed in bright orange, then accessorising must be a bit of a challenge.
The game itself however, is another matter.
Typical English Football – very quick, lots of commitment. You can tell it’s not the Premiership by the absence of millionaires rolling around the floor in apparent agony because they’ve broken a finger-nail.
Two late goals sends the Hatters home happy.
All of which has nothing to do with the subject of this post, apart from my choice of examples.
Comparing the table structure between different schemas is standard functionality for any self-respecting IDE. However, things get a bit more tricky if you’ve had a visit from the Prefix Pixie. He, she (or it if you’re table relationship diagram dropped out of a design tool) thought it’d be a good idea to give the same prefix to every table in the schema.

The result of this is that the tools in the IDE can’t recognize that tables with different names are meant to have identical structures.
So much for the “Premiership” of Database Development, it looks like we’ll just have to do a bit of D.I.Y. to see through the poxie pixie dust.
Dad would approve. Continue reading

Born Before Computers – fogey foibles and forsight for the humble insert

Apparently, I am considered by some to be stuck in my ways.
For example, Deb now refuses to stand with me in the supermarket queue because of my tendency to argue with the automated checkout.

This even extends into my working life where I have a colleague who is a bit more hip and with it when it comes to writing code.
The rest of us in the Oracle team – slightly older than this person it must be said – are apparently “BBC”.
This isn’t some reference to the venerable British Broadcasting Corporation, nor even to the BBC micro which was popular back in the 80’s.
Evidently, it is something of a disadvantage to have been “Born Before Computers”.
I’ll confess, I do write most of my database code in a text editior and run it via SQL*PLUS. Whilst I use an IDE for looking at stored database code, I’m not that keen on using it as a code environment.
As is usually the case, sometimes things are done in a certain way for years because that’s the best way to do it…and sometimes it’s simply because “that’s how we’ve always done it”.
The trick is, knowing which is which.

All of which brings us to the INSERT statement. Continue reading

Oracle Batch Job Logging – a framework for domestic harmony

Like most men, I have a standard of tidiness and cleanliness that I think of as “Bloke Clean”.
Deb’s standards are rather higher ( she would say normal). The difference can occasionally be a source of tension.
“Maybe I’ll just run off with that Steven Feuerstein bloke !”, she may have said during one of our discussions about the state of the study.
“Oh really ?”, I might retort, “and what’s he got that I haven’t ?”,
“Money, fame, talent and his own framework…not to mention a cleaner, I’ll bet”.
“Well…at least I have more hair”, I might say, disconcerted by her surprisingly comprehensive knowledge of someone who, it must be said, is not exactly famous outside of the wonderful world of Oracle.
“Not by much.” would probably have been the devastating reply.
Predictably, a compromise has now been reached…the upshot of which is that I’ve just spent the afternoon becoming intoxicated by the fumes from various cleaning products…and the study is now gleaming and all the papers filed away…and we’re getting a cleaner.
As for the money, fame and talent…well, I’ll just have to make do with the framework for now.
Truth be told, calling it a framework is overstating things a bit. But hey, it does give me an excuse to come up with a (possibly) amusing name. Continue reading

ORA-00845: MEMORY_TARGET error installing Oracle XE on Mint and Ubuntu

It was my turn to “cook” tonight. Deb was quite emphatic on that point. Continuing the fine and long-held tradition, sustained through generations of British manhood, I duly trudged down to the chippy.
Fish and chips, with that unique and exquisite smell of malt vinegar. Never mind all those fancy aftershaves, for us Brits it’s Sarsons…pour homme.
Except that, when I get to the shop, I find that I have no cash on me and they don’t accept cards.
No, not even “Chip and Pin”.
Eventually, the hunter gatherer returns ( having made a short detour to an ATM) to be greeted by the now ravenous family. Honestly, this cooking lark is all go.

It could be worse I suppose. I mean, the recipe for Victoria Sponge doesn’t suddenly stop working for no readily apparent reason, unlike, to take a random example, installing Oracle XE on Mint and Ubuntu.

When I wrote the original post, all was working perfectly. Mint 11, Oracle XE 11g, job done.
However, Mint 13 ( or Maya, if you prefer) is a bit of a different story. So, for that matter is Ubuntu 11.10 and above.

At this point, I’d like to say a big thanks to Gil Standen, whose comment on the original post was spot on in pin-pointing and solving this issue.

So, if you’ve found your way here having been frustrated in your installation attempts by this pesky error, what follows is an explanation of the issue, together with the steps that I used to resolve it on Mint 13. Continue reading

The CASE against DECODE and the Misery of Penalties

Euro2012 has come and gone. That sigh of relief is the sound of Deb reclaiming the TV remote and banning me from watching any more sport for the rest of the summer.
Spain have confirmed themselves as one of the great teams in history by winning yet again.
It has been said that they are boring. As far as I can see, the only boring thing about them is their predictability in not letting anyone else win.
By that measure, England are pretty boring as well although, if you wanted to be a bit more positive, you’d say consistent. How much of a lottery can penalties be when you lose all the time ?
I’m not even going to pretend that the above ramble connects in any way to the subject of today’s wander through the wacky world of ANSI SQL…although you may notice that I’ve taken inspiration from recent events for some of the examples.
When Oracle first came out, there was no ANSI standard SQL. There weren’t any other relational database on the market.
As a result, there are various programming constructs that are still a bit non-standard.
Yes, Oracle has introduced the ANSI standard equivalents over time and insisted that both the proprietary and ANSI syntax work in exactly the same way. This is true. For the most part.
I have already noted the advantage of ANSI join syntax when using more than one outer join.
Here, however, I’m going to turn my attention to a useful little feature of the CASE statement. Continue reading

Time travel with fixed_date

My Dad is a bit of a clever-clogs at the moment.
When he confidently predicted that Chelsea would beat Barcelona in the Champions League back in April,
I put this down to an affinity with the Chelsea squad which, lets face it, is rather nearer to his age-group than those at most other big clubs.
Since then however, he’s been on a roll, culminating in his unerring prediction that Sweden would beat France in the Euros.
This almost cephalopodic accuracy ( remember Paul the Octopus) is about to be put to it’s sternest test.
According to Dad, England will beat Italy on Sunday.
Hopefully, this is just another example of his prescience rather than a case of being swept up in the mood of the moment. Roy Hodgson has gone from being “why on did they go for this old codger” to “I always knew he was the man for the job” in the space of six weeks.
English football fans, fickle? I don’t know where you get that idea.
All of which provides a fairly tenuous link to the subject at hand – testing date sensitive changes in Oracle. Continue reading

Leading Zeros…the bleeding edge of TO_CHAR format masks

We’ve been busy playing with our new house.
Deb has re-arranged the furniture about three times since we moved in.
Well, she’s actually just specified where she wants the furniture, it’s me who has actually moved it about.
In fairness, she is the one who brings all the taste, style and interior design skills to our relationship. I’m more of the Igor who just does the legwork at her bidding.
My protestations about the importance of Euro 2012 have been met with the response that it can’t be that important a football tournament because Wales aren’t playing in it.
One of the benefits of moving into a new place is that stuff just works. You hit a light switch and the light comes on.
It’s a bit like using TO_CHAR to convert a number in Oracle really. Look, I’ll show you…
Continue reading