我的目標是open source,是不可能花錢買driver,所以要用Perl DBI,首先就要先安裝FreeTDS
再來就是照著下列步驟安裝Sybase DBD模組
得先安裝dbi套件 |
apt-get install libdbi-perl |
$ cd DBD-Sybase-1.16 |
|
#這一行很重要 |
|
$ export SYBASE=/usr/local/freetds |
|
$ perl Makefile.PL |
|
$ make |
|
$ make install |
|
|
There will be some output about missing libraries after perl Makefile.PL. These are normal. |
NOTE: here again make test is likely to fail. Writing your own simple test program is highly recommended!
Example Connect to a server with DBD::Sybase
#!/usr/local/bin/perl
#
use DBI;
my $dbh = DBI->connect("dbi:Sybase:server=JDBC", 'guest', 'sybase', {PrintError => 0});
die "Unable for connect to server $DBI::errstr"
unless $dbh;
my $rc;
my $sth;
$sth = $dbh->prepare("select \@\@servername");
if($sth->execute) {
while(@dat = $sth->fetchrow) {
print "@dat\n";
}
} |
|
|