Re: parameter cannot return more than 256 chars
"Frediano Ziglio" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
2008/11/30 Federico Alves <[email protected]>: > 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 > > 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 > > #!/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(); > > 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; > This work #!/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"); # exec testsql \@sessionid , \@IPAddress OUTPUT, \@ReceivedNumber OUTPUT, \@ANI OUTPUT , \@protocol OUTPUT, \@timeout OUTPUT my $query = "exec testsql ?, ? output, ? output, ? output, ? output, ? output"; my $sth = $dbh->prepare($query); $sth->execute('1120019620.8','','17274907253','16463835040',1,0); my (@data) = $sth->syb_output_params(); print "data ".join(' ',@data)."\n"; 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}); @data = $sth->syb_output_params(); print "data ".join(' ',@data)."\n"; $sth=undef; $dbh->disconnect; Note the exec syntax calling store procedure, exec must start the statement (no declare before). I didn't tested parameters name. freddy77