sudo apt install gcc make -y
wget -O - https://install.perlbrew.pl | bash
echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.profile
source ~/perl5/perlbrew/etc/bashrc
perlbrew install perl-5.33.8
perlbrew switch perl-5.33.8
perlbrew install-cpanm
####
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.2.20.tar.gz
tar xfvz freetds-1.2.20.tar.gz
cd freetds-1.2.20/
./configure --prefix=/home/username/tdslib
make
make install
####
export SYBASE=/home/username/tdslib
cpanm install DBI
cpanm DBD::Sybase --verbose --force
####
use warnings;
use strict;
use DBI;
use Data::Dumper;
runTest('');
runTest(';tdsLevel=CS_TDS_495');
sub runTest {
my ($tdsLevel) = @_;
my $dsn = "dbi:Sybase:server=172.28.79.294$tdsLevel";
my $UserName = 'myusername';
my $Password = 'supersecretpassword';
my $dbh = DBI->connect( $dsn, $UserName, $Password, )
or ( print "Can't connect to the DB: $DBI::errstr\n" and die );
print "\nTesting no placeholders, no results $dsn\n";
my $sth = $dbh->prepare("select 'test' where 1=0");
$sth->execute();
my $results = $sth->fetchall_arrayref( {} );
print Dumper $results;
print "\nTesting placeholders with results $dsn\n";
my $sthSecond = $dbh->prepare("select ? where 1=1");
$sthSecond->execute("test");
my $resultsSecond = $sthSecond->fetchall_arrayref( {} );
print Dumper $resultsSecond;
print "\nTesting placeholders with no results $dsn\n";
my $sthThird = $dbh->prepare("select ? where 1=0");
$sthThird->execute("test");
my $resultsThird = $sthThird->fetchall_arrayref( {} );
print Dumper $resultsThird;
$dbh->disconnect();
}