Wednesday, 29 August 2012

A Neat Trick with the IN predicate

I just recently learned this new trick with the IN() predicate in MS SQL. The following example is kept simple so that the logic should be obvious, but the really valuable lesson herein is that the arguments to the IN() predicate could be extended to include any number of columns, and therefore this is a general method for finding a match within any column(s) in a given table.
Here is the T-SQL:

USE AdventureWorks2008R2 -- change the database name to suit your version of the AdventureWorks db

SELECT  LastName
FROM    Person.Person
WHERE   'Lee' IN ( FirstName, LastName )

In AdventureWorks2008R2, this query returns 9 rows where the LastName is 'Lee' and 100 rows where the FirstName is 'Lee'.

On more small thing worth a note: the formatting is purposeful. It was generated by RedGate SQL Prompt, with an option set to preface the lines with a comma. The native SQL default is to suffix the column names with a comma, but that format can lead to hassles when you re-order the columns. If you have SQL Prompt, you're off to the races, but even if you don't, I would suggest that you format your SQL this way. The compiler doesn't care about white space, so make your life easier by using this formatting.

Saturday, 25 August 2012

Thinking about Thinking about Life and Death

To revise Rene Descartes, "I think that I think, therefore I think that I am."

I may have over-trivialized this rather deep question. It all goes back to Fernand LaPlace's (in retrospect rather idiotic) premise that if we could know the time and place and motion of every electron in the universe, then we could predict with 100% certainty the outcome of the universe at any given point in future-time.

Enter quantum theory, or its ancestor, The Uncertainty Principle. We can either know the location of an atom or its velocity, but never both; the mere act of observation changes the fact observed. This much has been proved to be a fact of reality.

We are coming close to what matters here, IMHO. If it turns out that the particular universe in which you and I dwell should prove nothing more than an involuted hypershpere. and that all my decisions were pre-ordained in an infinite loop of possible universes, then this argument strikes me as a cop-out. What we have at hand is one Actual Universe, in which x+y always equals y+x. That's all we have to go on. In theory, there may be another universe in which this basic truth does not hold true. But frankly, I don't believe it can exist, and here's why: in any such alternate universe, there must exist a redefinition of reality, such that said redefinition includes a saner perspective on the nature of events (i.e. events have causes, which in turn have causes, and projecting forward, events have results, which in turn have results).

I am tempted to apply this logic to foreign policy as practiced by various nations, but for the moment I shall let this contentious topic lie sleeping in its bed.

In the current GOP universe, women are evil, or at best, untrustworthy. Should a woman be "legitimately raped", then and only then should she be entitled to abort. Admittedly, Mr. Romney has retreated from this egregious statement, and even gone so far as to repudiate the speaker's right to wear the Republican flag.

But to be fair in this argument, I also recognize that advances in medical science can cause premature babies to survive, albeit with massively expensive interventions, but in theory that is beside the point. The Republicans are correct, in my opinion, in raising the question, "When does life begin?" Unfortunately, the answers may displease virtually everyone.

Suppose that the Catholic belief turns out correct -- that life begins at the moment of conception. One can imagine that in 20 or 50 years a "baby" created an hour ago could be extracted from its mother and fed via test tubes and such, and 9 months later become an actual baby. A knotty problem, to be sure, but not without the realm of futuristic reason. This could happen, and likely will, within the current century. And then what? What if it can be scientifically proved that one second after the moment of conception, a baby is viable? What does that do to a woman's right to choose?

I don't know. But I can see this battle coming rather than going away. With every new medical advance, the definition of viability grows shorter.

However, there is an alternative, as practiced in ancient Greece and Japan. In the former case, a baby was left alone for three days, and if s/he survived, then s/he became a person. In the latter case, it was held that a child was not a person until s/he achieved six months of age, at which point the soul became seated in the body, and the infant became a Person.

There is an even grimmer side to these arguments: if one is given the right to terminate a child deemed not yet a person, then why should this right to terminate not also extend to people no longer deemed to be persons? I'm thinking of the victims of Alzheimer's and similar diseases. I'm deeply uneasy with that, but as yet I'm unaware of a logical argument against this extension.

What is a Person? Is an acorn an actual oak tree or merely a potential oak tree? Is a 300-year-old oak tree to be considered nothing more than the fuel for the next forest fire? I don't know. I have seen some thousand-year-old trees and deemed it the worst sort of violence to cut them down. I have seen and swam with turtles two centuries old, and the thought of their becoming soup repels me. Both these citations work from a simple principle: what right do I have to kill anything older than me or for that matter, my parents? Any plant/animal that can survive more than a century ought to be valued solely on those terms. You and I have relatively brief life-spans. Numerous other species dwarf our expectations of longevity, regardless of medical advances.

And so let us leap to someone's imagined future, in which Immortality is possible (although affordable only by the ultra-rich). As one S-F writer expressed this, "What no one told us about immortality is, How many assholes you'd meet in 600 years."

I don't know about either of these questions, but I do think that we need to consider both.

Saturday, 18 August 2012

Assange and Asylum

Two days ago, the long and tortuous drama of Wikileaks, starring the handsome, silver-haired Australian-born Julian Assange, took another turn, when Ecuadorian Foreign Affairs minister Ricardo Patino announced that Mr. Assange had been granted political asylum by the Latin American nation. So now Mr. Assange is technically in Ecuador, but only in that small part of it that lies within Britain -- the embassy.
Meanwhile, the British government has clearly stated that Assange will be arrested the moment he leaves the embassy.
As with any drama, perhaps, the first problem is, Where to Begin? Some would say it begins with the founding of WikiLeaks. Others would say that the real beginning was the release of the torrent of  confidential, secret and top secret documents detailing US actions and personnel around the world, and the subsequent decision by the US government to get Assange at any cost, on any pretext, including the ridiculous notion that he could be charged with treason. (As to how could any citizen of any country other than the USA be charged by the USA with treason, that detail went overlooked.)
Still others would say that the story begins on 11 August 2010, when Assange arrived in Stockholm on a speaking trip arranged, in part, by "Miss A", a member of the Christian Association of Social Democrats. It was reported that Miss A agreed to let Assange stay at her apartment during the trip.
On 14 August 2010, Assange and Miss A attend a seminar hosted by the Social Democrats Brotherhood Movement, whose topic was "War and the Role of Media." Miss A and Assange reportedly had sex that night.
On 17 August 2012, Assange and "Miss W", a woman he met at the seminar three days prior.
Some time within the next three days, Misses A and W met with a journalist and expressed concerns with aspects of their sexual encounters with Assange.
On 20 August 2010, the Swedish Prosecutor's Office issued a warrant for Assange's arrest, on two charges, one of rape and one of molestation. Wikileaks quoted Assange as saying that the charges are "without merit" and that the timing is "deeply disturbing." (This refers to Assange's application for residency in Sweden and his plan to open a Wikileaks office in Stockholm; Sweden has laws protecting whistle-blowers.)
The next day the charges were withdrawn. One of Stockholm's chief prosecutors, Eva Finne, is quoted as saying, "I don't think that there is reason to suspect that he has committed rape." Karin Rosander, chief of communications for the Prosecutor's office, said that the investigation into the charge of molestation would continue.
On 1 September, Swedish Director of Prosecution Marianne Ny announced that the rape investigation would be reopened.
On 18 October, Assange was denied residency in Sweden. Shortly thereafter, Assange returned to London.
On 18 November, the Stockholm District Court approved a request to detain Assange on suspicion of rape, sexual molestation and unlawful coercion. Director of Prosecution Marianne Ny stated that Assange was unavailable for questioning.
On 20 November, Swedish police issued an international arrest warrant for arrest of Assange via Interpol.
On 8 December, Assange surrendered to London police, then taken to an extradition hearing.
Act II
Those interested in the blow-by-blow details can read them at For our purposes, we can jump-cut to the near-present, when suspicions began that it was the long arm of the American government that wanted its fingers around Assange's throat. Naturally, the US denied any such thing, only to be contradicted today (18 August) by the Sydney Morning Herald, in a story titled "US intends to chase Assange, cables show", from which I quote:

AUSTRALIAN diplomats have no doubt the United States is intent on pursuing Julian Assange, Foreign Affairs and Trade Department documents obtained by the Herald show.
This is at odds with comments by the Foreign Affairs Minister, Bob Carr, who has dismissed suggestions the US plans to eventually extradite Assange on charges arising from WikiLeaks obtaining leaked US military and diplomatic documents.
The Australian embassy in Washington has been tracking a US espionage investigation targeting the WikiLeaks publisher for more than 18 months.
The declassified diplomatic cables, released under freedom of information legislation, show Australia's ambassador, the former Labor leader Kim Beazley, has made high-level representations to the US government asking for advance warning of any moves to prosecute Assange.

Read more:

We are not quite yet at the climax in this powerful play of sex and politics, but clearly the audience's sympathies have been divided, several times over.
One camp sides with the position of the American government, regarding Assange as the bin Laden of the Internet, intent upon the destruction of the USA.
Its immediate opposition cites the American sacred cow of Freedom of Speech in Assange's defense, and adds to this that charges of treason, etc. are irrelevant since Assange is an Australian citizen.
Still another group argues that he ought to return to Sweden and face the charges. Some of the more extreme in this camp go further and argue that any defense of Assange amounts to blatant sexism. Its opponents argue that should Assange set foot in Sweden, that government would happily honor the US request to extradite him to face the music of an American court. Others argue that granting an extradition to the US might result in a death sentence for Assange.
In Canada, which refuses any requests for extradition made by any country in which the death penalty might result), opinion (as judged by letters to the CBC and virtually all the nation's important newspapers) in favour of Assange far outweighs that supporting the Swedish extradition request -- precisely because of the fear that a successful extradition to Sweden will, despite the outcome of any trial in that country, result in a subsequent extradtion of Assange to the US.
This writer's mind is mixed on this drama. I applaud Assange's intentions with Wikileaks, and deem it a strike against government secrecy and in favour of the people's right to know. On the other hand, I deem charges of rape exceedingly serious. On still another hand, I've read too much John Le Carre to dismiss the possibility of a setup engineered by the darker elements of US policy, and also seen too much to doubt the extent of the pressure the US can apply to its friends, not to mention the petulant reaction the US can be expected to take when its "friends" do not acquiesce (as for example the reaction against France when it refused to play along in Iraq).
So I have come up with a final Machiavellian move: Ecuador should make Assange a citizen and a diplomat of its nation, thereby extending all the rights and privileges of diplomatic immunity. Hence, the freedom to ride out of the embassy in a limousine, and board a plane to Ecuador. The irony here, of course, is that Ecuador is among the least friendly nations to the concept of freedom of expression.

All along, Assange has polarized discussion over the WikiLeaks web site, whose most notorious (or heroic, depending on your viewpoint) act was to release hundreds of thousands of documents detailing US secret actions in countries all over the world.
Meanwhile, another group of

Friday, 10 August 2012

Move over, hockey! Football (aka soccer) is Canada's game now!

Canada's official game is lacrosse, not hockey, but thanks to several factors, Football (i.e. soccer) has now become our new official game.

Men get no credit for this: the women did it all. First, the heartbreaking game last Monday (August 6, 2012), in which a questionable call by the referee resulted in a fourth goal by the USA over our splendid Canadian women. Led by Christine Sinclair, we held the lead three times, and then in the dying seconds lost, thanks to a highly questionable call by the referee. Our keeper did indeed hold the ball for six seconds, but the referee was assisted by the USA player who was counting aloud. And therein turns a game of monumental proportion.

And then, here comes the thing that defines Canada as a nation: our coach, Mr. John Herdman (, himself a legend prior to moving to our shores and transforming our women into, not a but the Force to be reckoned with), gathered his women together and said "Rise Up!" (c.f. The Parachute Club, -- well, not in those precise words, but he did say something to our team, and those lovely and gifted women did indeed rise up. France quite clearly outplayed us, but as Mr. Herdman said in a post-game interview, "It's all about putting the ball in the back of the net." France came a fraction of an inch close to winning the Bronze. A couple of brilliant saves by our keeper Erin McLeod, and a couple of lucky post and crossbar hits by the French, and at the end of the day, our women won in the final seconds of Overs. Our lovely heroine, previously unsung, Diana Matheson, upon receiving a pass, and with only a split-second to decide, made the correct decision, a side-kick, guaranteed to stay low.

Canada -- not just me! the whole nation -- wept with joy. And, I shall admit it as my own take, not ascribing it to any other Canadians, a certain amount of lust for these magnificent women.

The success of our football team is hugely due to Mr. John Herdman, whose post-game interview was remarkably Canadian in its humility

The large influx of immigrants from such nations as India, Pakistan, China, Malaysia, and of course all the Caribbean nations (Trinidad and Tobago, Jamaica, and all the islands named St. something -- Kits, Vincent, etc.)

All this adds up to "Our new national game is Football!" Later for hockey and lacrosse. It's a new dawn, a new day, and its name is Football! Let's stop calling it Soccer. If any game in the world deserves the name "Football", it is surely a game in which hands, elbows, etc. are disallowed.

Here's this voice for Canada's new official game: Football.

Wednesday, 8 August 2012

Ribbon (Cloud) of Darkness Over Me

Previously, I have expressed serious doubts about the move toward the Cloud. My doubts have recently been expressed by Steve Wozniak, which given my peon status and his icon/legend status, suddenly lends credence to our skepticism.

Mr. Wozniak points out something that had not previously occurred to me, the ownership of clouded data. Although I pretend that I keep up with jurisprudential rulings, they come too fast and furious for any mere mortal to stay abreast, and secondly, I am at best a jailhouse lawyer rather than one upon whose opinion you should risk your future, unless of course you're already in jail, in which case you probably lack the funds for someone more educated than I... but that is another story.

My initial doubts about Cloud technology lay in my fear that any given Cloud site could be compromised, and that all my confidential documents regarding the impending release of my Next Killer App could be read  by unauthorized persons. But now my doubts have increased exponentially: suppose that my CSP (Cloud Service Provider) gets compromised to the point of a total system failure. Then my alleged ability to connect to documents of interest from my tablet, my desktop, etc. are suddenly all dead at once, and I am forked! The PowerPoint presentation due to present at 9:05am tomorrow is totally compromised. The transactional database that I promised my client 24/7 is now hosed, costing us $750k an hour. The nuclear-facility management system that I promised is now down, thanks to some third-world criminals or even local criminals with some misguided mission to deliver us from Evil. An entire power-grid goes down, affecting 24 states in the USA and the most significant two provinces in Canada, and perhaps London, England and its attendant stock markets.

To the extent that we bet on Cloud technologies, we risk everything. That is my conclusion, and it has been so for a couple of years. I'm happy to welcome the most esteemed Mr. Wozniak into the fold of skeptics, and much more important, I pray that some people in positions of influence shall listen to us.

All this is not to say that Clouds are by definition bad. Au contraire: we just need to step up and realize that any given cloud could die in a minute, and that the other Clouds need to be able to step up and recover from this disaster. However, given that the Cloud-folks are still in the competitive mode of marketing, as opposed to the next step (utilities), I expect them to be unwilling to protect each other's assets, which reduces to You and Me. They are in it for themselves, not for You and Me. That's how capitalism works, and this ultimately is why I do not yet trust Cloud technologies.

What I would want to know from any Cloud vendor is this:

1. What happens to my data is your entire site gets compromised?
2. How secure is my data from illegal penetration?
3. Can I sue you for loss of any data that my firm deems highly confidential and proprietary?
4. Does my uploading of my data mean that you own it, or does it remain mine/and/or my company's?

In the absence of excellent answers to these questions, there is no way I would do a deal with the given cloud player of interest.

Call me pessimist. An optimist says that this is the best of all possible worlds.
A pessimist agrees.