>> From: "Kairam, Raj" <[EMAIL PROTECTED]> >> Subject: sql output from dbi as an xml file >> >> My environment: >> HP-UX 11.0 >> perl 5.005_03 >> Apache 1.3.12 >> Oracle 8.1.6 >> DBI 1.14 >> DBD-Oracle-1.06 >
Before I get jumped on, I think fetchall_hashref was not available in DBI 1.14? So you may have to upgrade or use a different technique. cp -- http://www.pryce.net > From: cp <[EMAIL PROTECTED]> > Subject: Re: sql output from dbi as an xml file > > [ email to list and user directly] > > Here is a short example using XML::Simple available from CPAN. Forgive the > inelegant text wrap. This example takes a table of usernames and user > numbers, and emits XML. > > #!/usr/local/bin/perl -w > > use strict; > use XML::Simple; > use DBI; > use Data::Dumper; > > my $dsn = 'dbi:mysql:clients;host=localhost'; > my $user = 'mmarti'; > my $pass = '10072000'; > > my $dbh = DBI->connect($dsn, $user, $pass, {RaiseError=>1}); > die "Connect Failed\n" unless $dbh; > > my $sth = $dbh->prepare(qq( > SELECT agentID, > concat(lastname, ', ', firstname) as username > FROM users ) ); > > $sth->execute(); > my $keyattr = 'agentID'; > my $hashref = $sth->fetchall_hashref($keyattr); [snip rest of script]
