Posts from January 2010

why cant people understand date arithmetic ?

    AND TO_NUMBER(TO_CHAR(appt_start_dt + 9/24, YYYYMMDDHH24MISS)) <=
    TO_NUMBER(TO_CHAR((TO_DATE(:b1, DD/MM/YYYY HH24:MI:SS)),
                                     YYYYMMDDHH24MISS))`

Please can a clever Oracle person explain, in English, the precise semantics of this WHERE clause snippet in the comments below.

I realise this construct and variants thereof have probably been discussed ad infinitum on Oracle WTF but I just don't get it.

I don't know whether this SQL was written by a human being or a third party ETL tool but it doesn't matter. Currently, all ETL tools are written by humans in any case.

Why do people struggle so much with date arithmetic ?

When I was a little boy, I used to say 'Only 43 days to my birthday now, Dad'. Although I didn't know it at the time I could have written this as

    sysdate + 43 = :my_birthday

I even understand that TRUNC(SYSDATE) is midnight - it just seems fairly intuitive and logical to me.

My tiny brain can even understand the concept of date subtraction - last Wednesday was two days ago and Manchester City's last trophy was almost 34 years ago.

I understand that a date is a date is a date. I realise that a date is not an orange. I realise that a date is not a string and I only see dates in SQL Developer because that was a design decision to perform an implied conversion using the default date format and a useful user friendly feature.

I understand that if I want to display the date and be assured of the date format I need to convert it to a string using TO_CHAR with the appropriate date format mask.

I understand that Unix systems (and the next generation blogging platform, Habari) stores 'dates' internally as the number of seconds that have elapsed since the Unix epoch on 01 January 1970 00:00:00.

But look again at that code snippet. The author is obviously familiar with the Oracle functions TO_CHAR and TO_NUMBER but why in the name of God does he convert a date to a string to a number and then compare the resulting outputs ?

What is the meaning of that generated 'number' - 20100129143559 ? 'Twenty billion, one hundred thousand and and one hundred and twenty nine million, one hundred and forty three thousand and five hundred and fifty nine. Or something. Why is that a useful number ?

Why did he waste time and energy doing do all that typing ? Is he working on a top secret defence project that requires him to obfuscate the code ? Maybe he is paid by lines of code ? The author is clearly aware of some elements of date arithmetic in Oracle because he used '+ 9/24' to add 9 hours to the appointment start date.

Maybe there was a useful index defined on APPT_START_DT that he wanted to suppress for performance reasons.

I'm not sure but I have an awful suspicion that the object associated with the bind variable :B1 may already be declared as a DATE data type but hey, let's convert it to a date using TO_DATE - just to be sure, to be sure.

Why didn't he simply use

    AND appt_start_dt + 9/24 <= [TO_DATE] :B1

Why ?

Happy Anniversary

This years Carling Cup Final between Aston Villa and Manchester United will take place at Wembley on Sunday 28th February 2010.Curiously, this date marks the exact 34th anniversary, to the very day, of Manchester Citys last trophy.

After United defeated Millwall 3-0 in the 2004 FA Cup Final, all the United players changed into shirts numbered '36' in a tribute to the young player, Jimmy Davis, who had recently died in a car accident.

Today I have written to the club to see whether United could do something similar to mark the anniversary of Dennis Tueart's spectacular overhead kick that beat Newcastle in the 1976 League Cup Final. My proposal is for United to sport shirts sporting a MASSIVE '34' while Dennis Tueart could be the club mascot for the day, wearing a pale blue and white retro scarf.

34 years

When we go to Old Trafford, we will take that banner down. This is the last year it will be displayed because we will win.

Roberto Mancini - 6 January 2010

34 years

the wit and wisdom of Gary Cook

This football club will be without doubt the biggest and best in the world. People dont like to hear it but Ill make no excuses for saying it, and I will never stop saying it because I truly believe it with the resources and capabilities that we have - and when, not if, we're at Wembley having beaten Man United yet again !'

Gary Cook - Mad Hatter Saloon, New York, 22 January 2010.

34 years.

Rooney and Bellamy

fun with keywords

Some of the varied and bizarre keyword searches leading visitors to this site merely confirm this blog is the ramblings of a confused madman. Here is a selection from the start of the year

  • 'dyslexic blog' - curiously spelled correctly.
  • 'crucifixion blog' - listen United are in debt and suffering a dip in form but don't do anything hasty now.
  • 'why linux will never' - come on, you simply can't leave me dangling like that.
  • 'breasts chessington' - hoping your mates didn't publish that photo of you, on the log flume, flashing your assets.
  • 'brightside software enterprises friendorfoe' - stealth marketing finally starts to pay off.
  • 'famous captive animals' - Skippy (the bush kangaroo) and Lassie.
  • 'handsworth exoctic escort' - there's absolutely nothing exotic about Handsworth, trust me.
  • 'hoax messages on friends reunited' - the ghost of the cruel, heartless Janet Oldsgate strikes again.
  • 'how can i get back my lost virginity' - please send an international money order for £250 to PO Box 729.
  • 'life has dealt me with a cruel card' - don't tell me, hang on. Was it the '8 of Diamonds' ?
  • 'my car keeps cutting out and the bonnet is steaming' - stop blogging immediately and call The AA.
  • 'pubsubhubbub is a lot easier than it sounds' - easy for you to say.
  • 'the balls of allah explosive underpants' - priceless. What a superlative name for a blog/album/house/dog !
  • 'what do you think is the most important decision in our life' - Will these underpants last another day ?
  • 'fucking overlapping partitions when im installing linux' - language, Timothy. Nice assumption that the swear word would be included in relevant posts

milkman of human kindness

uk

Sometimes your faith in humanity is restored.

The DEC Haiti appeal has raised over £25 million just from the news coverage alone. This exceeds the £20 million raised by last year's Children in Need campaign which (while still a worthy cause) is mercilessly peddled and trailed by the BBC for two long weeks.

Don't forget to mark your donation as 'Gift Aid' which allows DEC to reclaim 28p for every pound given.

Steve Jobs on design

‘Make it look good! Thats not what we think design is. Its not just what it looks like and feels like. Design is how it works.” — Steve Jobs

So very true. Via a comment on an interesting blog post comparing Tumblr to Posterous.

Ironically, this short post would have been better suited to a one liner, throwaway post correctly labelled and nicely formatted as a quotation on a service like, well Posterous or err, Tumblr but I am trying to consolidate all my efforts into this blog.

Arthur Smith nails it

uk

This country is shit. The food is shit, the government is shit, the weather is shit, the transport system is shit, education is shit, life is shit, death is shit, I am shit.

As this country grinds to a halt yet again after a light dusting of snow, a timely and apt quote from Arthur Smith whose autobiography 'My Name is Daphne Fairfax' I can highly recommend.

the mechanics of IT

IT

Last year, I visited a customer in Swindon. When I arrived at the office, I noticed some water dripping from the underside at the front of my car. I didnt have time to investigate or get my hands dirty so I subconsciously hoped it was just condensation from the air conditioning unit and tried to forget all about it.

After work, I managed to navigate Swindon's world famous roundabout of roundabouts and finally locate my hotel. When I parked, I noticed the temperature gauge was reading high - very high. Sure enough, I got out of the car to see steam pouring out of the bonnet and was greeted by the familiar smell of anti-freeze.

I still didn't want to get my hands dirty so I opened the bonnet and just stared at the problem, hoping that would miraculously fix it. Then I checked in to my room and rang the AA. I introduced myself to the operator as 'Hi - my name is Norman and I'm an alcoholic.'

The AA man duly arrived before 'The One Show' had even finished. We both stood looking at the engine knowingly before he asked: 'Now, Sir, what seems to be the problem ?'

'Well, I think it's pretty minor and easy to fix. It's just the top hose has perished and needs replacing.'

'Oh I see, Sir. Why do you think that ?'

'Well, when the engine was running, steam was pouring out of the top corner of the radiator - right there where the water hose joins.'

'OK, Sir. Thanks for that. Please could you just turn the engine over for me so I can take a look myself ?'

Engine on. Water and steam billowing out. Smell of anti-freeze. Temperature gauge rising.

'Whoa ! That's fine, Sir. Engine off now, please. Well it's not your hose, Sir. The problem is over here. It's your bleed screw, Sir. Look (flips the screw from the middle of the radiator). This bleed screw has sheared off in half. Quite a common problem on this model. Seen it a couple of times now.'

I felt a little sheepish (but very relieved that a solution was in sight) and the man from the AA, James, filled the radiator with 13 pints of cold water and I followed him to a local garage where we parked and he kindly drove me back to the hotel so I could wash my hands.

The next morning, I walked into the customer's offices to be excitedly greeted with 'Oh good - glad you're here. We have got problems. Serious problems. Performance problems. On production.'

'Ah OK - what seems to be the problem ?' 'Well it's the database, you see. It's the hard disk - 99% busy. Partition 27b on logical volume 7 is overheating. Oh and another thing that might be relevant - the hit ratio is right down at 72.7%'

'OK - thanks for that. Do you think you could just start the system up for me and I'll take a look myself ?'

meaningless annual stats review

That was the year that was. Statistics for 2009 with the comparative numbers for 2008 in brackets.

Analytics-dashboard

Summary

  • 29,901 visits (43,732)
  • 39,545 page views (63,095)
  • 1.32 pages per visit (1.44)
  • Average time on site - 48 seconds (54 secs)
  • 91.2% new visits (90.6%)

Search Engines

  • Google - 22,627 (32,830)
  • Yahoo - 381 (704)
  • Bing - 168 (N/A)
  • AOL - 128 (229)
  • Ask - 115 (195)

Referrers

  • identi.ca - 575 (229)
  • avc.com - 222 (348) Disqus post linked by Fred Wilson
  • google.com - 216 (primarily Reader)
  • oracle-base.com - 169 (225)
  • disqus.com - 101

Platform

  • Windows - 81.4% (85.7%)
  • Macintosh - 11.9% (10.3%)
  • Linux - 5.1% (3.26%)
  • iPhone - 0.6% (0.2%)
  • iPod - 0.2%
  • Symbian, Android, PS3 - < 1%

Browsers

  • IE - 42.5% (56.5%)
  • Firefox - 41.4% (33.6%)
  • Safari - 7.2% (6.2%)
  • Chrome - 5.4% (N/A)
  • Opera - 1.6% (1.3%)

Content

  • Blog - 3,990
  • Review of Virgin Media V+ box - 4,666 (June 2007)
  • Virgin Media V+ upgrade - 1,871 (March 2007)
  • High Definition TV on Virgin Media V+ - 1,378 (December 2007)
  • intelligent automatic follow/block script for Twitter - 1,303 (April 2008)
  • pictures of a Virgin Media V+ box - 1,273 (June 2007)
  • 25 reasons you should use Disqus - 1,270 (April 2008)
  • how I ditched iTunes and started living with Foobar 2000 - 810 (October 2009)
  • Beware of Dixons Tax Free shopping - 791 (October 2005)
  • Posterous leveraging Tumblr themes - 729 (September 2009)

Posts

  • 79 (94)