Subject: | Does it work with DB2 |
Date: | Mon, 20 Aug 2007 09:17:54 +0200 (CEST) |
To: | bug-DBIx-XML_RDB [...] rt.cpan.org |
From: | morten bjoernsvik <morten_bjoernsvik [...] yahoo.no> |
Hi
I'm unable to get this working with DB2, I've searched the source and the DBI connect string should be correct, same program works fine with Mysql.
Not critical. I just used a few minutes to find a simple dbtoxml dumper.
There are lots of other modules to use.
Thanks
[mbj@demolinux DBtoXML]$ ./db2xml.pl -sql='select * from result' -filename=trans_8583_prod.xml
DBI connect('DBI:DB2:database=secana;host=localhost','db2inst2',...) failed: [IBM][CLI Driver] SQL1013N The database alias name or database name "" could not be found. SQLSTATE=42705
at /opt/perl/lib/site_perl/5.8.8/DBIx/XML_RDB.pm line 46
Connection failed
(in cleanup) Can't call method "disconnect" on an undefined value at /opt/perl/lib/site_perl/5.8.8/DBIx/XML_RDB.pm line 67.
Can't call method "DoSql" on an undefined value at ./db2xml.pl line 29.
#!/opt/perl/bin/perl -w
use strict;
use warnings;
use DBIx::XML_RDB;
use Time::HiRes qw(time);
use Getopt::Long;
my $sql = undef;
my $filename = "data.xml";
GetOptions(
"sql=s" => \$sql,
"filename=s" => \$filename,
);
die("Error: sql must be defined\n") if(! defined $sql);
my $driver = 'DB2';
my $hostname = 'localhost';
my $database = 'secana';
my $user = 'db2inst2';
my $pass = 'start1';
my $dsn = "DBI:$driver:database=$database;host=$hostname";
my $t0 = time();
my $dbx = DBIx::XML_RDB->new($dsn, 'DB2', $user, $pass);
$dbx->DoSql($sql);
open(my $XML, ">$filename")
|| die "Could not open file for writing: $! \n";
print $XML $dbx->GetData();
close $XML;
printf("Read in from database in %.2fsec\n",time()-$t0);
--
Morten Bjoernsvik
---------------------------------
Alt i én. Få Yahoo! Mail med adressekartotek, kalender og notisblokk.