Skip to Content.
Sympa Menu

freetds - Re: [freetds] DBD::ODBC + FreeDTS fails

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] DBD::ODBC + FreeDTS fails
  • Date: Fri, 23 Jun 2006 09:13:02 +0200

>
> KERTEL - Maxime MARAIS wrote:
> > Hi all,
> >
> > I am trying to use dbi::ODBC instead of dbi::Sybase in Perl
> scripts (I
> > use FreeTDS as a driver to connect to an MS-SQL Server
> 2000). The aim is
> > to be able to use placeholders (ex. "SELECT * FROM PERSONS
> WHERE NAME =
> > ? AND ACTIVE = 1") as it fails when trying to prepare
> statements with
> > dbi::Sybase, displaying a segmentation fault. (I already
> wrote about
> > this a few days/weeks ago).
> >
> > I installed unixODBC, set up odbc.ini, and performed a few
> successfull
> > requests using isql to get connected to the database I plan
> to use with
> > my Perl scripts.
> >
> > Now, I plan to install DBD::ODBC. I exported DBI_DSN
> ('dbi:ODBC:<dsn>'),
> > DBI_USER ('sa'), DBI_PASS ('****'), ODBCHOME ('/var'), ran
> successfully
> > `perl Makefile.PL`, `make` but did not pass `make test`.
> The tests fails
> > when running t/20SqlServer with the following error :
> >
> > DBD::ODBC::st execute failed: (DBD: st_execute/SQLExecute
> err=-1) at
> > t/20SqlServer.t line 210.
> >
> > I ignored the problem and installed anyway in order to see
> if it could
> > work with my perl script. But it also fails with the error `(DBD:
> > st_prepare/SQLPrepare err=-1)`. I try to run a simple select query.
> >
> > Any idea ?
> >
>
> I've been getting that error a lot recently as well. I'm using a very
> similar setup as you, but with SQL Server 7.
>
> I've found that you've got to do:
>
> $sth->finish;
>
> after *absolutely* *everything* you do, and then some :) I
> also have to
> clone ( $dbh->clone ) database handles everywhere, as you
> don't seem to
> be able to do more than 1 thing at a time with a database handle. It's
> pretty messy.
>
> OK, so I'm probably being a bit harsh. You don't have to do
> all this for
> *every* statement that you execute - sometimes you can
> continue without
> a $sth->finish ... but then code that runs perfectly for months will
> suddenly start failing with the error you're getting above, and you'll
> bash your head against a wall all day trying to figure it
> out, and when
> you add a $sth->finish in between the previous $sth->execute and the
> current command that's failing, everything magically starts working
> again. I'm still feeling a little agro over this because it happened
> yesterday ...
>
> If $sth->finish doesn't fix it for you, then try posting the entire
> block of code we're dealing with. Also try running the command run the
> SQL Server console. Sometimes errors don't quite make it all the way
> from SQL Server.
>

I'm sorry but this is mainly a limit of TDS protocol, not FreeTDS..
there are two mainly workaround
- cache results reading all rows before sending another query
- use cursors... currently under implementation...

freddy77





Archive powered by MHonArc 2.6.24.

Top of Page