
DBD::TSM - Perl DBD driver for TSM admin client

use DBI;
my ($server_name,$user,$password)=(...); #or set DBI_DSN,DBI_USER,DBI_PASS
my $dbh=DBI->connect("DBB:TSM:$server_name",$user,$password,
{RaiseError => 0,
PrintError => 0}) or die $DBI::errstr;
#If you use environment variable $dbh=DBI->connect();
my $sth=$dbh->prepare("select node_name from nodes") or
die $dbh->errstr;
$sth->execute() or die $sth->errstr();
print "@{$sth->{NAME}}\n";
$sth->dump_results();

DBD::TSM is a DBI Driver to interface DBI with dsmadmc. You could use all the command possible with dsmadmc with the Power of DBI. I don't test all the DBI capabilities.
To work you need to have:
dsmc query session command
dsmadmc -id=<user> -pa=<password> -se=<Your Server Name stanza> query status
When you set AutoCommit (the default), I add -itemcommit in command line.
You have to ways to track execute error in script. It's mandatory with TSM because, it send a 11 return code for empty statement. I propagate this return code.
So you have two methods to not exit from script:
1. First, set RaiseError => 0 in connect method
my $dbh = DBI->connect($dbi_dsn, $dbi_user, $dbi_pass, {
RaiseError => 0,
});
2. Use eval {}; block for execute fonction
eval {
$sth->execute($select);
};
None by default.

DBI(3).
TSM Client Reference Manual.

I'm not using TSM API. So, I do one session for each statement. It's a Pure Perl Module.
Be carefull with join statement because we could have duplicate field name. I detect this duplicate field and send a warning message.

Rewrite fetch to use a filehandle to read dsmadmc output line by line to redure memory requirement. I have some idea, need just time to do it. Not sure it works on Windows.

Laurent Bendavid, <lbendavid@cpan.org>

Copyright (C) 2005 by Laurent Bendavid
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.