Skip to Content.
Sympa Menu

freetds - Re: ints don't work, trailing null on strings

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: James Ponder <james AT squish.net>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: ints don't work, trailing null on strings
  • Date: Wed, 18 Oct 2000 22:43:44 +0100


On Wed, Oct 18, 2000 at 05:32:09PM -0400, Brian Bruns wrote:
> Can you tell me if you see this problem using TDS version 4.2 as well as
> 7.0?
> (do this by doing an 'export TDSVER=42' before running perl)

I hope this helps... (PS. Maybe you could say in the docs somewhere about
this export business, I've been recompiling every time I wanted a different
protocol!)

$ export TDSVER=42
$ ./test.pl
OUTPUT: 'hello' (length 6)
$ export TDSVER=70
$ ./test.pl
OUTPUT: 'hello' (length 6)

#!/usr/bin/perl -w

use DBD::Sybase;
use strict;

my $dsn = 'DBI:Sybase:server=xxx.xxx.xxx.xxx;database=xxx';
my $user = 'xxx';
my $pass = 'xxx';

my $dbh;

defined($dbh = DBI->connect($dsn, $user, $pass))
or die "Failed to connect to MS SQL database\n";

sub Q {
my $sth = $dbh->prepare($_[0]);
die 'Error: '.$_[0].':'.$dbh->errstr."\n"
if (!$sth or !$sth->execute);
return $sth;
}

my ($sth, $out);

#Q("DROP TABLE wibble");

Q("CREATE TABLE wibble (moo CHAR(20))");
Q("INSERT INTO wibble (moo) VALUES ('hello')");
$sth = Q("SELECT moo FROM wibble");
$out = ($sth->fetchrow_array)[0];
print "OUTPUT: '$out' (length ".length($out).")\n";
Q("DROP TABLE wibble");


Best wishes, James
--
James Ponder; www.squish.net




Archive powered by MHonArc 2.6.24.

Top of Page