Skip to Content.
Sympa Menu

freetds - Re: [freetds] parameter cannot return more than 256 chars

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Frediano Ziglio" <freddy77 AT gmail.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] parameter cannot return more than 256 chars
  • Date: Mon, 1 Dec 2008 09:56:19 +0100

2008/11/30 Federico Alves <sales AT minixel.com>:
> This is the issue that has been killing me. If I set tds_version=8.0 in
> freetds.conf, then my perl does not pass any parameter at all. If I remove
> the tds_version from the server definition in freetds, then the parameters
> pass back and forth, but only 256 chars. You are right that the information
> works fine with tds_version=8.0, but then how do I make my perl script work
> again? This has been happening for ever. The only way to make my perl script
> work, which uses DBI and DBD-Sybase 8.0, is to remove the tds_version from
> freetds.conf and thus I guess it goes back to 4.2. But It makes little sense
> anyway because I compiled freetds with version 8.0
>

Configuring with tds version 8.0 change only the default, you can
always override it.
I would change script to use DBD::ODBC, probably there is something
wrong with CTLib.

> tsql -C
> Compile-time settings (established with the "configure" script)
> Version: freetds v0.82
> freetds.conf directory: /usr/etc
> MS db-lib source compatibility: yes
> Sybase binary compatibility: no
> Thread safety: yes
> iconv library: yes
> TDS version: 8.0
> iODBC: no
> unixodbc: yes
>
> Dear Frediano, can you please use your privileged mind and figure out why
> this perl script works only in 4.2 emulation and not in 8.0? If you log into
> my server the script is located on /var/lib/asterisk/agi-bin
>

It's not a emulation, server support both protocol 8.0 and earlier.

> #!/usr/bin/perl
>
> use strict;
> use DBI;
> my $server = "";
> my $db = "minixel";
> my $username = "sa";
> my $password = "";
>
> my $dbh = DBI->connect("dbi:Sybase:minixel:1433", 'user', 'pwd', {PrintError
> => 0});
> die "Unable for connect to server $DBI::errstr"
> unless $dbh;
> $dbh->do("use $db");
> my $query = "declare \@sessionid varchar(64), \@IPAddress varchar(40) ,
> \@ReceivedNumber varchar(30) , \@ANI varchar(20) , \@protocol int ,
> \@timeout int
> select \@sessionid = '1120019620.8', \@IPAddress = '', \@ReceivedNumber =
> '17274907253', \@ANI = '16463835040', \@protocol = 1, \@timeout = 0
> exec testsql \@sessionid , \@IPAddress OUTPUT, \@ReceivedNumber OUTPUT,
> \@ANI OUTPUT , \@protocol OUTPUT, \@timeout OUTPUT";
> my $sth = $dbh->prepare($query);
> $sth->execute();
>

This query can't work using protocol 8.0 !!! Output parameters are not
returned to client using exec command. Microsoft change this behavior
so or you use select after exec (like in tsql test) or you use
protocol 4.2 (limiting varchar to 255 characters) or you use RPC
directly (I don't know how to use it using DBD::Sybase, using
DBD::ODBC you have to prepare a "{call sp?name(parameters)}" query
binding with output specification)

> do {
> while(my $dat = $sth->fetch) {
> print "TYPE $sth->{syb_result_type}\n";
> print "Data @$dat[0] , @$dat[1] , @$dat[2] \n";
> if($sth->{syb_result_type} == 4042) { # it's a PARAM result
> print "Number: $dat->[0] \n";
> print "Varpar: $dat->[1] \n";
> }
> }
> } while($sth->{syb_more_results});
>
>
> $sth=undef;
> $dbh->disconnect;
>

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page