PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: sy50027 at milton dot sbi dot com (Simon Yaminian)
Subject: Re: Accessing @@rowcount global variable
Date: Jul 21 1998 5:26PM

> From owner-SYBPERL-L@listproc.net Tue Jul 21 13:00:37 1998
> From: Michael Peppler 
> Mime-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Date: 	Tue, 21 Jul 1998 09:56:56 -0700 (PDT)
> To: SybPerl Discussion List 
> Subject: Re: Accessing @@rowcount global variable
> X-Listprocessor-Version: 8.2.07 -- ListProc(tm) by CREN
> 
> Simon Yaminian writes:
>  > 
>  > > 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
>  > > -- 
>  > > Michael Peppler         -||-  Data Migrations Inc.
>  > > mpeppler@datamig.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.
> 
> 
> I just use the data that Sybase returns to me. The only way that I
> could provide you with the @@rowcount info earlier would be to process 
> all the rows in the query internally.
> 
> The Sybase server would have to do the same thing to return an
> accurate @@rowcount value *before* returning the rows. This is a
> serious performance issue. Please read the documentation on DBCOUNT()
> and/or ct_res_info() in the Sybase OpenClient manuals for more info
> behind this issue.
> 
> Michael
> -- 
> Michael Peppler         -||-  Data Migrations Inc.
> mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
> Int. Sybase User Group  -||-  http://www.isug.com
> 
> 
   Thanks for all the replies.

   I understand that behind every concept, there is an implementation issue which often times
affects performance. However what makes a great system greater is to be able to absorb challenges
which often times seems impossible and make it transparent to the user. Certain things may not be
immediately practical but they should not be discarded for the same reason. After all challenges
are not impossibilities but rather impracticalities made practical.

Regards

Simon Yaminian