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: Brian Bruns <camber AT umcc.ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: OK, DBD::Sybase/FreeTDS interaction problem.
  • Date: Tue, 28 Sep 1999 22:20:10 -0400 (EDT)



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.

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')
>
>





Archive powered by MHonArc 2.6.24.

Top of Page