Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Bind Parameter Problem with DBD::Sybase and FreeTDS

by thezip (Vicar)
on Sep 06, 2006 at 08:15 UTC ( [id://571394]=perlquestion: print w/replies, xml ) Need Help??

thezip has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I've been recently working on a small maintenance app for my shop, and have run across some issues with getting bind parameters to work.

As for the environment, I have a FreeBSD 5.3 box running Apache 2.0 and Perl 5.8, connecting to a MSSQL Server 2000 database. I installed the FreeTDS package and configured it to utilize DBD::Sybase as was detailed in CleverFox's tutorial (node 392385).

Everything works great (in the simplified query below) if I don't use the bind param -- but once I put it back in, I get the following message in my webserver error log:

[Tue Sep 05 16:06:01 2006] [error] [client] [Tue Sep 5 + 16:06:01 2006] ct_send(CS_DESCRIBE_INPUT) returned 0 at + /usr/local/lib/perl5/site_perl/5.8.5/mach/DBD/ line 133., r +eferer: http://website/cgi-bin/

After searching the web for awhile, I found a few references to known issues with FreeTDS's parameter binding mechanism for DBD::Sybase.

I'm hoping that perhaps someone has also seen this issue and can suggest a specific workaround given my current environment.

Thanks in advance!

use strict; use DBI; use DBD::Sybase; my $CX = <...database connection info...> sub executeSelect { my($CX, $SQL, $params) = @_; my $resultset = []; # Get the database handle for the currently selected connection my $dbh = _getDBHandle($CX); my $sth = $dbh->prepare($SQL); my @params = @$params; for (my $I = 0; $I <= $#params; $I++) { $sth->bind_param($I + 1, $params[$I]); } $sth->execute(); while (my @row = $sth->fetchrow_array) { push(@$resultset, \@row); } return $resultset; } ### MAIN ### my $SQL = qq( SELECT JobN, JobDescription, CustomerOrderN, BookedDate, DueDate, Qu +antity FROM OpenJob WHERE JobN = ? ORDER BY DueDate desc); my $params = [ 68104 ]; my $records = executeSelect($CX, $SQL, $params);
Where do you want *them* to go today?

Replies are listed 'Best First'.
Re: Bind Parameter Problem with DBD::Sybase and FreeTDS - Try DBD::ODBC with iodbc and freetds instead
by imp (Priest) on Sep 06, 2006 at 11:52 UTC
    I recommend using DBD::ODBC with iodbc and freetds instead.

    Note that freetds has to be compiled for iodbc, and DBD::ODBC does as well. Here is the install sequence I used recently:

    # Install libiodbc wget && tar -xzf libiodbc-3.52.3.tar.gz && cd libiodbc-3.52.3 && ./configure && make && make install # Install freetds wget +le.tgz tar -xzf freetds-stable.tgz && cd freetds-0.63 && ./configure -with-iodbc && make && make install # Configure odbc.ini echo "[pcas2006] Database=pcas2006 Server= TDS_Version=8.0 Port=1433 Driver=/usr/local/lib/" > /etc/odbc.ini # install DBD::ODBC perl -MCPAN -e'get DBD::ODBC' && cd ~/.cpan/build/DBD-ODBC-1.13 && export ODBCHOME=/usr/local && perl Makefile.PL && make && make install
    I found that DBD::ODBC also seemed to handle some binary data better - DBD::Sybase seemed to truncate the data in one case when \0 was in the data.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://571394]
Approved by Corion
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-15 06:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found