Skip to Content.
Sympa Menu

freetds - [freetds] Prepared statement + date fields

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: KERTEL - Maxime MARAIS <mmarais AT kertel.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Prepared statement + date fields
  • Date: Thu, 01 Jun 2006 13:05:54 +0200

Hello,

Programming Perl scripts connecting to MS-SQL Databases and able to be
ran on both Linux and Windows plateforms (using [DBD::Sybase+FreeTDS] on
Linux and [DBD::ODBC+MSSQL driver] on Windows), I try to use
$dbh->prepare($sql) and $sth->execute($values) statements.
My scripts work fine on Windows plateform but I am unable to run them on
Linux because of a segmentation fault fired when executing
$dbh->prepare($sql). It seems FreeTDS does not support the placeholder
functionality when ODBC does (ie. "SELECT * FROM MyTable WHERE MyData = ?").

Example :

#!/usr/bin/perl -w

use DBI;

my $name = "user";
my $pass = "pass";
my $conn = 'DBI:Sybase:server=myserver';
my $dbh = DBI->connect($conn, $name, $pass);
print "W0 - Preparing\n";
my $sth = $dbh->prepare("SELECT ISDATE(?)");
#### Note I use a parameter ('?') in the sql query.
print "W0 - Executing\n";
$sth->execute('1970-01-01');

This scripts displays :
W0 - Preparing
ct_send(CS_DESCRIBE_INPUT) returned 0 at
/usr/local/lib/perl/5.8.7/DBD/Sybase.pm line 133.
Segmentation fault.


I am also facing another problem. When executing "SELECT getdate()", $sth-->fetchrow_array also hangs up with a segmentation fault. I have to replace "SELECT getdate()" with "SELECT CONVERT(varchar, getdate())" in order to get $sth-->fetchrow_array work.

Could you please confirm placeholder are not supported ? Could you also
tell me if such a fonctionnality is planned to be supported in the future ? Could you tell me more about date fields ?

Thanks forward.

--
Maxime MARAIS
Kertel.





Archive powered by MHonArc 2.6.24.

Top of Page