Skip to Content.
Sympa Menu

freetds - Re: OK, DBD::Sybase/FreeTDS interaction problem.

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Michael Peppler <mpeppler AT peppler.org>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: Re: OK, DBD::Sybase/FreeTDS interaction problem.
  • Date: Wed, 29 Sep 1999 06:57:34 -0700 (PDT)


Brian Bruns writes:
>
> Ok, I follow the flow of what is happening. I'm just not sure what should
> be happening under ctlib. The doc is a little weak on the subject.
>
> When freetds runs a query with no rows returned, ct_results() returns
> CS_END_DATA and sets res_type to CS_CMD_DONE. DBD::Sybase takes this and
> sets the query to a nonactive state (DBI_ACTIVE_off()).
>
> Curiously enough, SQSH doesn't seem to mind. I'll check tommorow what the
> behaviour should be. Once that is known it should be trivial to fix.

Here's a trace of this query using the Sybase libraries:

-> execute for DBD::Sybase::st (DBI::st=HASH(0x815e540)~0x8114910)
syb_st_execute() -> ct_command() OK
syb_st_execute() -> ct_send() OK
st_next_result() -> ct_results(4040) == 1
ct_res_info() returns 5 columns
describe() retcode = 1
<- execute= -1 at none.pl line 24.
Retrieving data 0
-> fetchrow for DBD::Sybase::st (DBI::st=HASH(0x815e540)~0x8114910)
st_next_result() -> ct_results(4046) == 1
ct_execute() final retcode = -205
syb_st_fetch() -> st_next_results() == 4046
syb_st_fetch() -> resetting ACTIVE, moreResults, dyn_execed
<- fetchrow= ( ) [0 items] at none.pl line 30.
-> finish for DBD::Sybase::st (DBI::st=HASH(0x815e540)~0x8114910)
<- finish= 1 at none.pl line 40.
-> disconnect for DBD::Sybase::db (DBI::db=HASH(0x80cee5c)~0x80cee50)
syb_db_disconnect() -> ct_close()


The first result type returned by ct_results is CS_ROW_RESULT. At that
point we get the row description, and then we fetch the first row. As
ct_fetch() returns CS_END_DATA, we call ct_results() again, which now
returns CS_CMD_DONE, and now we reset the active status of the
statement handle.

So it looks like you return CS_CMD_DONE one step too early in this
case.

Michael

>
> Brian
>
> On Tue, 28 Sep 1999, Jaye Mathisen wrote:
>
> >
> > I'm running on FreeBSD, using FreeTDS 0.46, and DBD::Sybase-0.19,
> > DBI-1.12. The server is currently running SQL 6.5, SP 5A.
> >
> > The dopey question I asked about the rowcount thing turned out to
> > have a bit more significance than I first thought, because my problem
> > was that I couldn't detect queries that returned 0 rows.
> >
> > The following output occurs from the enclosed (short) script. I don't
> > believe the while() loop should succeed, because the query returns 0
> > rows.
> > But I get this error message, rather than just skipping the loop.
> >
> > Here's the output:
> >
> > backmaster# ./ex.pl
> > Unknown property 7
> > Retrieving data 0
> > no statement executing at ./ex.pl line 44.
> >
> > The query is "select * from customer where 1=0". sysusers can
> > be substituted easily for customer, the point is just to return
> > 0 rows. And you'll have to change the "use plat" to "use
> > whateverdatabase".
> >
> > Any ideas on what to look for?
> >
> > --- short script ---
> > #!/usr/local/bin/perl
> >
> > my $q = "select * from customer where 1=0";
> >
> > use DBI;
> >
> > if(-f "./PWD")
> > {
> > open(PWD, "./PWD") || die "$_/PWD is not readable: $!\n";
> > while(<PWD>)
> > {
> > chop;
> > s/^\s*//;
> > next if(/^\#/ || /^\s*$/);
> > ($l, $r) = split(/=/);
> > $Uid = $r if($l eq UID);
> > $Pwd = $r if($l eq PWD);
> > $Srv = $r if($l eq SRV);
> > }
> > close(PWD);
> > }
> >
> > my $dbh = DBI->connect("dbi:Sybase:server=$Srv", $Uid, $Pwd, {PrintError
> > => 0});
> >
> > die "Unable to connect to $Srv: $DBI::errstr"
> > unless $dbh;
> >
> > my $rc;
> > $rc = $dbh->do("use plat");
> >
> > my $sth;
> >
> > $sth = $dbh->prepare("$q") || warn "Problem\n";
> >
> > if ($sth->execute) {
> >
> > my $rows = 0;
> > my @dat;
> >
> > print "Retrieving data 0\n";
> > while (@dat = $sth->fetchrow) {
> > print "Retrieving data\n";
> > ++$rows;
> >
> > foreach (@dat) {
> > $_ = '' unless defined($_);
> > }
> > print "@dat\n";
> > }
> >
> > $sth->finish;
> > }
> >
> > $dbh->disconnect;
> >
> >
> > ---
> > You are currently subscribed to freetds as: camber AT ais.org
> > To unsubscribe, forward this message to $subst('Email.Unsub')
> >
> >
>
>
> ---
> You are currently subscribed to freetds as: mpeppler AT peppler.org
> To unsubscribe, forward this message to $subst('Email.Unsub')
>

--
Michael Peppler -||- Data Migrations Inc.
mpeppler AT peppler.org -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list AT isug.com




Archive powered by MHonArc 2.6.24.

Top of Page