Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

VSarkiss (704)

VSarkiss
  (email not shown publicly)
Yahoo! ID: vah3sark (Add User, Send Message)

I haven't really taken the time to set this up, but you can look at my home node [perlmonks.org] on Perl Monks.

Journal of VSarkiss (704)

Thursday October 30, 2003
10:27 PM

Heavy and medium lifting

[ #15489 ]

I mentioned the incredible tedium of writing DB2 embedded-SQL programs in here a while ago, and of course I wasn't about to stand for that. I wanted to write a program to do the tedious stuff for me.

My first attempts met with abject failure: DBI and DBD::DB2 don't give you metadata unless the underlying DBMS supports the INFORMATION_SCHEMA views (which DB2 doesn't; and it wouldn't suffice for what I needed anyway), and the type information was the sine qua non of what I was trying to do.

Then I found a way to get metadata for arbitrary SQL using one of IBM's sample embedded-SQL/C programs. But as soon as I got that working, I knew there wasn't a chance I'd write something like the code generator in C. Just the thought of doing a ton of strstr and strtok calls almost made me break out in a rash. Really, life's too short.

A couple of days ago, somebody in a meeting said, "Oh, I figured you'd just dump the type data in a file", and the lightbulb went on. I used IPC::Open2 to feed the SQL file to the C program I'd cribbed from IBM, and read the results back. Presto! DB2 metadata in Perl!

I got the code generator working today and it spit out 95% of everything I needed. Put me ahead days, if not weeks.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.