Tracing for fun and (tk)profit

If you ever wanted proof that time is relative, just consider The Good Old Days.
Depending on your age, nationality, personal preferences etc, that time could be when rationing finally ended; or when Trevor Brooking won the Cup for West Ham with a “bullet” header; or possibly when Joe Carter hit a three-run homer to seal back-to-back World Series for the Blue Jays.
Alternatively, it could be when you were able to get on to the database server and use tkprof to analyse those tricky database performance issues.

In these days of siloed IT Departments, Oracle trace files, nevermind the tkprof utility are out of the reach of many developers.
The database server itself is the preserve of Unix Admins and DBAs, groups which, with good reason, are a bit reluctant to allow anyone else access to the Server at the OS level.

Which is a pity. Sometimes there is just no substitute for getting into the nitty gritty of exactly what is happening inside a given session.

For those of you who miss The Good Old Days of tkprof, what follows is an exploration of how to access both trace files and even the tkprof utility itself without leaving the comfort of your database.
I’ll go through a quick recap of :

  • how to generate a trace file for a session
  • using tkprof to make sense of it all

Then, coming bang up to date :

  • viewing a trace file using an external table – and why you might want to
  • Using a preprocessor to generate tkprof output
  • implementing a multi-user solution for tkprof

Continue reading

Oracle External Table Pre-processing – Soccer Super-Powers and Trojan Horses

The end of the European Football season is coming into view.
In some leagues the battle for the title, or against relegation is reaching a peak of intensity.
Nails are being bitten throughout the continent…unless you are a fan of one of those teams who are running away with their League – Bayern Munich, Juventus, Celtic…Luton Town.
In their fifth season since relegation from the Football League to the Conference, Luton are sitting pretty in the sole automatic promotion place.
Simon is desparately attempting to balance his “lucky” Christmas-cracker moustache until promotion is mathematically certain. Personally, I think that this is taking the concept of keeping a stiff upper-lip to extremes.

"I'll shave it off when we're definitely up !"

“I’ll shave it off when we’re definitely up !”

With the aid of a recent Conference League Table, I’m going to explore the Preprocessor feature of External Tables.
We’ll start with a simple example of how data in an External Table can be processed via a shell script at runtime before the results are then presented to the database user.
We’ll then demonstrate that there are exceptions to the rule that “Simple is Best” by driving a coach and Trojan Horses through the security hole we’ve just opened up.
Finally, in desperation, we’ll have a read of the manual and implement a more secure version of our application.

So, without further ado… 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

Windows batch scripting and learning to love German footballers

Windows scripting – the computing equivalent of the German football team.
I suppose I should qualify that statement, if only to avoid irate comments from any German readers.
The German National side has always been admired rather than loved.

Yes, they have been more successful than most, and have produced more than their share of great players (Beckenbauer,
Rummenigge, Matthaus…add you’re own favourites here). Yet they are rarely cheered by the neutral.
This lack of popularity probably has quite a bit to do with the fact that, in major finals, Germany seem to be condemned to be cast as the bad guys against the forces of footballing light (the Total Football of Cruyff’s Netherlands in 1974), or the plucky underdog (Czechoslovakia in 1976, Denmark in 1992).

The footballing triumph regarded by Germans above all others is Das Wunder von Berne.
The 1954 World Cup Final was meant to be a coronation of one of the great teams in history. The Hungarians of Ferenc Puskas came into the final on the back of an unbeaten run going back 4 years, including an 8-3 thrashing of West Germany in the group stages of the tournament.

After eight minutes of the final, all was going to plan with Hungary already 2-0 up. What followed was one of the great comebacks – and great upsets – in the history of the game. Rahn completed the miracle with his second of the match, and the winner, with six minutes left.
Sepp Herberger, Fritz Walter and Helmut Rahn are the German equivalent of Alf Ramsey, Bobby Moore and Geoff Hurst. Outside of Germany, they remain largely unknown.
Incidentally, apologies for that 1966 reference, but unlike Germans (Italians, Spaniards…) we English have only that single triumph, or the odd glorious failure to look back on.

So, back to Windows batch scripting. It’s widely used, but next to the richness and variety of it’s siblings in the unix world, it appears hideously limited. However, there are times where it is simply unavoidable.

What follows are some basic examples of

  • Accepting user input
  • Using variables
  • a simple for loop ( because there is no other kind )
  • branching
  • interaction with an Oracle database

At this point, I have to say that if you are on a Unix/Linux system, or have access to Cygwin, there are far better ways of working with your database.

For any remaining poor unfortunates… Continue reading

VPN access on Mint using rdesktop

This post was going to begin with one of my occasional bulletins on the fortunes of Luton Town, beloved club of my mate, Simon. However, the man himself has been bitten by the blogging bug and the resultant musings on all things Teradata ( and various other topics) can be seen here.
So instead, I’d invite you to consider the Nordic majesty that is Milford Sound. Nestled in the heart of Fjordland in New Zealand’s South Island, this watery expanse evokes awe and wonder, even in a land where jaw-dropping scenery is always just around the next bend.
Milford Sound was itself named after the equally picturesque sounding Milford Haven. Yes, Milford Haven in Wales, site of one of the largest oil terminals in Europe.
I should note at this point that the Welsh Ambassador has demanded that I point out that Milford Haven does have some nice bits.

Moving swiftly on, in the vain hope of avoiding domestic disharmony, my point is, the fact that two things share common characteristics doesn’t mean that they are necessarily identical.

All of which provides a somewhat tortuous link to the subject of this post, namely, setting up remote desktop access via a VPN on Mint.

Now, you’d think this was pretty much the same as on Ubuntu, and it is…up to a point. Continue reading

Oracle XE – Speeding up Startup and getting Nofications on the Desktop in Ubuntu

Oh the tension. 2-0 up at half-time. Visions of last-day drama and an eleventh-hour escape floating tantilisingly before my eyes. Then, grim reality. A second-half collapse and the prize is snatched away once more. So, this is what it must be like to be an Arsenal fan.
I know that they say misery loves company, but it’s not really any consolation. Yes, my beloved West Ham have been relegated from the Premiership.

In an effort to rouse myself from the resultant depression, I decided to have a look at addressing one of those minor annoyances that I’m always intending to get around to but somehow never quite do. In this case, it’s how to get confirmation that my Oracle XE database has started before trying to connect to it ( and that it’s shut down before I turn off my computer). Continue reading

A Quick guide to Cygwin commands for the deprived of the DOS world

Things have been a bit hectic in my world lately. In addition to all the festive seasonal joy ( shopping, family, in-laws, out-laws etc) I’m in the process of changing jobs.

It is the way of such things that sometimes, you just can’t quite squeeze everything in.

The one thing I didn’t get time to finish before leaving was this DOS to BASH guide ( despite several evenings spent hacking away on Windows). So, for the CIG guys…well, it’s traditional – all kids know that there’s got to be at least one Christmas present that you can bash. Sorry. Continue reading

Twiddling with tar – Differential backups on Linux

When I first mentioned the title of this post to my girlfriend, she misheard and thought there was an extra “t” at the end.
One hasty explanation later I have avoided banishment to the shed. All of which is mildly ironic as the tar command comes with a whole alphabet of options, many of which are about to get used here.

As it’s name suggests, the venerable tar command ( Tape ARchive) has it’s roots back in the time when computers were the size of a small semi in Dagenham and punch cards and tapes were the acme of the Programmer’s art.

Now I’m going to use it for backing up data on my assorted Ubuntu machines.
What I want to do here is :

  • work out how much data I need to backup
  • create a full backup of all of my data
  • make sure I know what files have been backed up
  • test the restore of a file from the backup
  • make subsequent incremental backups

In the course of this odyssey, we will discover that du has a human face and that tar has a bit of a yellow streak.
There are several things that can go horribly wrong when playing around with tar, so I’m going to test everything on a small subset of files…that I have safely stored elsewhere.
Speaking of which… Continue reading

Apache, Aliases and Zenity on Ubuntu – how to control your ego

It’s the weekend. My girlfriend is staring at the screen in ferocious concentration as she does battle with her latest essay plan for the Masters she’s studying for.
Evicted from the desk and consigned to a dark corner, I’m trying to find some diverting, productive and, above all, quiet, way to amuse myself. As any parent will know, when the kids are quiet, it usually means they’re up to something… Continue reading

Zen and the Art of Shell Scripting

You know what it’s like with a little kid at his birthday party. They get all excited, eat far too many sugary foods and then run around behaving badly.
Oracle Openworld has ended for another year, and not a minute too soon. Hopefully, Larry will have an early night and stop being so excitable and upsetting all those jolly nice open source types he had round.
Meanwhile, in the comparative calm of the backwater that is this blog, I’ve been getting all Zen. Well, zenity, to be precise. Yep, I’ve decided that some my batch scripts needed to get all GUI with Gnome and zenity looks to be the tool to do it.
What follows is an account of my first steps with zenity followed by a demonstration of some of it’s capabilities. Continue reading