Tuesday, 19 August 2008

De-mystifying SQL Update Triggers

I've been looking at the murky world of SQL Server 2000 Update triggers recently, and none of it's as straightforward as I'd imagined. There seems to be unnecessary confusion around the columns_updated() function, which is all explained brilliantly in this article. I realised where I was going wrong with my user update trigger - because the user table had so many columns, the standard "catch-all" function to see if anything had changed, only referenced the first eight columns of the table. This all runs at single bit level, so 8 pieces of data is all that will be calculated in a single reference to the columns_updated() function. Therefore this is fine for a database table with up to eight columns:

IF (substring(columns_updated(), 1, 1)) > 0

-- Do stuff...

However I needed four of these statements to include all the user columns:

IF (substring(columns_updated(), 1, 1)) > 0 OR (substring(columns_updated(), 2, 1)) > 0 OR (substring(columns_updated(), 3, 1)) > 0 OR (substring(columns_updated(), 4, 1)) > 0
-- Something has changed, therefore update the record...

Rather laborious, but preferable to checking each column's status separately. Do read the article, it's quite excellent, hats off to Andy Warren.

Thursday, 14 August 2008

Auto-suggest without ColdFusion 8

I've been Googling on auto-suggest frameworks in ColdFusion, and EVERYONE assumes that you're using CF8. If you're maintaining an old site, and don't have the luxury of CF8, I can recommend this list of auto-suggest frameworks.

I had a good look at "mgBox", which is neat, but the data source aspect is a bit on the annoying side, being rather too verbose to seem elegant. I much prefer "Wick", which is easy to customise, and just uses a plain Javascript file as its data source. It only took a couple of hours to get it working with the .js file being generated from a SQL query via ColdFusion. All rather impressive! If you've seen any other frameworks that you like, then let me know.

Sunday, 3 August 2008

Michael Vaughan, My Lord... Michael Vaughan

It it with great sadness that Michael Vaughan today resigned as the England cricket captain. He's had a bad run of form this year, and losing the current series 2 - 0 to South Africa has made up his mind - it's time to go. Personally I think he should have waited until next week's final test match has finished, but he is clearly in a state of mental disarray, and it would be wrong of him to continue playing if he felt unable to perform or to lead the team.

Vaughan carried on the good work where Nasser Hussain left off in 2003 - adding some genuine fighting spirit and pride to an historically erratic and ineffective England team. There have been ups and downs, but his finest moment was recapturing the Ashes in the summer of 2005. That will live on as one of the finest Test series ever played, a truly inspiring performance from a very happy and committed team. Wonderful stuff. For that, I thank Michael Vaughan from the bottom of my heart.

On to the subject of his replacement - who should lead the team? Kevin Pietersen is being tipped as the obvious choice, but personally I wouldn't choose him, purely because he has no captaincy experience at any level. Being a world-conquering batsman is one thing, but grasping the nuances of the game and knowing how to handle individual players is a rare gift, and there's no evidence so far that he possesses it. My greatest fear is that Pietersen will gain the captaincy, and that it will slowly destroy his confidence, and with it his batting ability.

For my money, Chris Read is the man to take over from Vaughan. He is a truly gritty and determined cricketer, and arguably the finest wicket-keeper in the world. Currently in charge of Nottinghamshire, who he had lead to the top of Division 1 in the county championship, he would solve the keeping option, AND the captaincy option, while adding his services as a steady and often attacking batsman.

All will be revealed tomorrow.... watch this space.

Friday, 1 August 2008

Colbourne's First Law of Pavement Dynamics

Right, it's about time I revealed a theory that I've been postulating for the last few months. It may be peculiar to Mid Sussex - I'm not sure, as the pavements in Brighton are so over-crowded. I need to road-test it in other parts of the country.

The theory is this:
"Given a long, empty pavement, which only you and one other person are using, you can bet your bottom dollar that you and said person are competing for exactly the same piece of pavement, to the point where you're almost walking in each others' shoes."

I see this in action almost every day, and considering that there could be 300 metres of empty pavement in either direction, just what are the chances of it happening? Maybe it's time to start buying Lottery tickets.