Listing 1. Trevor Price's Perl Script that Queries the Sample
Database Called Northwind
#!/usr/bin/perl
#
# test the db2 dbi driver
#
use DBI ;
$user = 'sa' ;
$passwd = 'password' ;
$dbh = DBI->connect('DBI:Sybase:server=file1',
$user, $passwd);
$dbh->do("use Northwind");
$action = $dbh->prepare("sp_help") ;
$action->execute ;
$rows = $action->rows ;
print "rows is $rows\n";
while ( @first = $action->fetchrow_array ) {
foreach $field ( @first ) {
print "$field\t";
}
print "\n";
}
exit(0);
Copyright © 1994 - 2019 Linux Journal. All rights reserved.