Monday, March 31, 2008

Comparing CHAR values

Here is a table with a single row of data.

SQL> create table my_tab (c2 char(2))
2 /

SQL> insert into my_tab (c2) values ('Y ')
2 /

1 row created.


Which of the following queries will match that row?

select * from my_tab where c2 = 'Y'

select * from my_tab where c2 = 'Y '

select * from my_tab where c2 = 'Y '

If you said all three you get a cigar (providing you live in a jurisdiction where such infernal devices are still permitted).

SQL> select * from my_tab where c2 = 'Y';

SQL> select * from my_tab where c2 = 'Y ';

SQL> select * from my_tab where c2 = 'Y ';

The reason is due to Oracle's rules for comparing blank-padded datatypes. If the two values are of differing sizes Oracle pads the smaller variable with the requisite number of blank spaces. Obviously it is documented.

On the whole I think this is a boon - CHAR columns are a pain in the neck at the best of times, without having to worry unnecessarily about additional RPAD calls. This is unfortunate if you are relying on 'Y ' being different to 'Y'; but if your application depends on trailing spaces for data integrity then you probably have bigger problems.

Friday, March 14, 2008

Hacking a pacemaker

In the last few days I have read a couple of pieces which quote the William Gibson dictum "the future has already arrived, it’s just not distributed evenly". Confirmation that we are indeed living in a science-fiction story arrived today in the shape of a message on the Full Disclosure list: hacking a pacemaker. Security researcher Gadi Evron cites a report in the NYT.
" The threat seems largely theoretical. But a team of computer security researchers plans to report Wednesday that it had been able to gain wireless access to a combination heart defibrillator and pacemaker.

They were able to reprogram it to shut down and to deliver jolts of electricity that would potentially be fatal . if the device had been in a person. In this case, the researcher were hacking into a device in a laboratory. "
What a great way to assassinate somebody....

Wednesday, March 12, 2008

Code quality metrics

Whenever two or three developers gather together they will argue over the best tool for editing code. Once they've chewed the spearmint out of that they will commence a heated discussion on ways to measure code quality. But I think this cartoon by Thom Holwerda pretty much nails it.

Tuesday, March 11, 2008

Ellison on hostile acquisitions

Fake Steve Jobs links to a piece in the New Yorks Times by Andrew Ross Sorkin on Larry Ellison's thoughts about the recent spate of hostile acquisitions (many of them by Oracle). Larry demonstrates his knack for a well-turned line. I have never worked for Big Red so I am not in a position to comment on his assessment of Oracle's friendliness. But he has a very sound view of sales and marketing people:
“What makes you think that engineers are happier, for example, working at PeopleSoft rather than at Oracle?” he asked. “Who says it’s unfriendly?”

The people who are most likely to scream and moan about an acquisition are the marketing people and salespeople — who, by the way, are the most dispensable, he said.

Thursday, March 06, 2008

What... is your favourite colour?

Yesterday somebody called Pradeep posted a question in the OTN PL/SQL forum asking for careers advice. He is a VB programmer working in a Microsoft code factory (in India I would guess). He wanted to know what the Oracle job market was like, because he wanted thinking of training as an "oracle developer".

The reaction from some of the forum regulars was dismissive. Here is a sample:
"There are so many career/job opportunities in IT that to ask on a forum like this for career direction advice is just ... Well, just not a good idea.

But put yourself in Pradeep's position. (Note the following is an extrapolation: I don't really know his circumstances). A combination of the commoditization of IT and outsourcing has produced software sweatshops, where you, the developer equivalent of a sharecropper, churn out code chunks to be assembled into systems elsewhere. It's repetitive, stultifying and without much room for personal growth. Even if you do hear of a better job you know you are surrounded by dozens of other sharecroppers who stand just as much chance of getting it as you.

So Pradeep has thought to himself, Oracle is a famous company but he doesn't know anybody who works as an Oracle developer. That means he is going to face much less competition for any Oracle job which might arise. You might find this optimistic but it is thinking outside of the box. He then shows further initiative by posting a question about Oracle careers on the OTN forums. Because he thinks that the people who answer questions there will be helpful - which they are - and they will have the relevant knowledge - they all have careers in Oracle development.

What he hadn't anticipated was that quite so many people regard the PL/SQL forums as a suitable place for rehashing Monty Python jokes and discussing antiquated programming languages but not for offering careers advice. It's a funny old world.

Wednesday, March 05, 2008

Openness: CMG's unsecret sauce

The CMG Wake last Friday was a lot of fun. Estimates have placed attendance at around the 700 mark, which made the pub extremely crowded and rather noisy.

Whilst queuing at the bar I got talking to someone who left the company in 1987. He put his finger on the unique thing about CMG. He now lectures in Business Studies and cites CMG to his students as an example of openness in business. In CMG everything was open: the personal files hung in open cabinets in the office. You could read anyone's file - from their job application form to their latest staff appraisal. Yes, including salary.

That's the bit which gets people. When Brian Behlendorf talked about introducing open source principles in general working practices at OOW2K6 one of the questions afterwards was whether such openness, if taken to its logical extreme, would result in everybody knowing how much everybody else earns.

Well, why not? Partly it's just embarrassment - many people would rather discuss their medical conditions or their bedroom fantasies than their pay-packet. But the main objection seems to be "I wouldn't want my colleagues to know how much I earn". The objectors are presuming that they earn more than their co-workers. I think some of those people would be very interested to discover that all their colleagues get paid more than them. And they'd want to know why.

The accepted wisdom in CMG was that open salaries promoted fairness: the management couldn't play favourites because anybody could ask them "How come Joe Soap gets paid 10K more than me?" and have to provide an answer. In practice there were probably all sorts of anomalies - especially in pay rates across different divisions - but it felt fair. I know people who work in law firms and finances houses where discussing your salary with co-workers is a disciplinary offence. Most companies aren't that fierce but very few companies are as open as CMG was.

I don't think openness was the only thing which made CMG special, but it was one of the reasons why so many people feel affection for the company, even if they did stop working for it over twenty years ago. Although I'm sure the promise of a free bar helped too.

Update: 06-MAR-2008

Currently Dilbert has an amusing take on payroll secrecy. I think this link will eventually break, so get it whilst it's hot :D

Tuesday, March 04, 2008

Better late than never

There is a new white paper on OTN called Upgrading from Oracle Database 9i to 10g: What to expect from the Optimizer. I am working on a 9i project which is considering upgrading to 10g (quite possibly the last such in the world) so I think we'll find it useful. Of course, it might also be helpful to people who have already done the upgrade and are experiencing performance problems in their new environment.