Coding judo

VSarkiss on 2002-10-02T15:33:50

I'm currently working on Microsoft SQL Server 2000, using something called Data Transformation Services, or DTS. It's basically MS trying to work into the data warehouse market, by edging out competitors like Informatica.

You build a DTS package out of components, which do things like establish connections, execute SQL, transform columns, etc. One component allows you to write scripts using VBScript or JScript, or if you install it yourself, Perlscript. Guess which I picked.

Well, in typical MS fashion, the software doesn't do everything that the documents claim. In some cases you have to read very carefully, because the wording seems to be precisely crafted to make it sound like it does more than it actually says. After two days of struggle to make Perlscript work in that environment, yesterday I gave up and decided to try writing VBScript. Well, I'd forgotten a lot of how (badly) it worked, so I figured I'd write some small tests to make sure that what I wanted would work at all. Small surprise, it did seem to work in VBScript, if I copied their example code carefully.

So what was the problem? I decided to go back and carefully re-craft the code from VBScript to Perl. I found that this resulted in code slightly different from what I had written previously, mainly due to not fully understanding how Win32::OLE implements the COM interfaces. (Should I use $obj->{foo}->Value? or $obj->foo()? or ...) When I got it to work, I quickly tucked away its guts in a module, and verified I could call from it DTS. Hallelujah! Free at last! I can now re-use the code without copying-and-pasting, and without putting up with VBScript.

So, boys and girls, remember: sometimes the way to win is by giving in first, then turning it to your advantage.

BTW, I have to mention: if you're going to try anything with Win32::OLE, the best resource I've found is Dave Roth's web site. Invaluable information, in the form of tips and example. Thank you, Dave!