Up Prev Next
From: sy50027 at milton dot sbi dot com (Simon Yaminian)
Subject: Re: Accessing @@rowcount global variable
Date: Jul 21 1998 4:42PM
> From owner-SYBPERL-L@listproc.net Tue Jul 21 11:52:51 1998
> From: Michael Peppler
> Mime-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Date: Tue, 21 Jul 1998 08:45:11 -0700 (PDT)
> To: SybPerl Discussion List
> Cc: firstname.lastname@example.org
> Subject: Re: Accessing @@rowcount global variable
> X-Listprocessor-Version: 8.2.07 -- ListProc(tm) by CREN
> Simon Yaminian writes:
> > >
> > > Simon Yaminian writes:
> > > > Hello,
> > > >
> > > > The number of rows affected by a query is reflected in the @@rowcount
> > > > global variable. Is this variable accessible through Sybperl and if it is
> > > > how?
> > >
> > > In DBlib is DBCOUNT().
> > > In CTlib it's
> > > $rows = $dbh->ct_res_info(CS_ROW_COUNT);
> > >
> > I tried using the DBlib version, DBCOUNT() right after the
> > $dbh->dbsqlexec
> > call and it returned -1. The dbsqlexec call was issued after building
> > the query as a batch of commands using multiple dbcmd calls. Is this a
> > permissible scenario for using DBCOUNT()?
> @@rowcount (and hence DBCOUNT()) only return valid data for a SELECT
> operation *after* all the rows have been processed. This is the normal
> behaviour (and is the same on other SQL servers, such as Oracle).
> Michael Peppler -||- Data Migrations Inc.
> email@example.com -||- http://www.mbay.net/~mpeppler
> Int. Sybase User Group -||- http://www.isug.com
Thanks for your reply.
I just think that it would have been much more meaningful if @@rowcount
was available before the rows were processed. Why? Because first of all,
if you are going through the rows one by one, you can keep track of the
total rows by merely updating a counter yourself. Second, knowing the rowcount
ahead of time helps in the decision making process and proper preparation in
processing the rows especially when dealing with large rowcounts. If you think
this is just an opinion, consider the following analogy.
You are trying to walk from street A to street B and you also have the town's
map with you. However the map can not tell you how many blocks you need to walk
before you reach your destination unless you have finished walking and made it
to your destination. I wonder if that map has any significant and sensibe usage!
Please take that for whatever it's worth to you, maybe I am just mistaken
about the concept.
Thanks & Regards