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: "Brittingham, John" <john dot brittingham at attws dot com>
Subject: RE: Problem with dbnextrow
Date: Apr 28 2003 5:08PM

Michael,
I tried that. Still the same problem.
I tested the query and it will return apprpriate data from the command
line. I fact dbresult() returns 1 row, but it does not run the second
while loop.

-----Original Message-----
From: Michael Peppler [mailto:mpeppler@peppler.org]
Sent: Monday, April 28, 2003 8:04 AM
To: Sybperl-L Mailing List
Subject: Re: Problem with dbnextrow


On Fri, 2003-04-25 at 18:43, Brittingham, John wrote:
> Having problems with dbnextrow. I know the query is valid: I also know
> that it returns 1 if I use $dbh->dbresults. The problem is that it
> returns nothing for $dbh->dbnextrow. Anyone have any idea why this
> would be happening?

Well - you need to call dbresults() before you can call dbnextrow().

Some comments below:

First - I'm betting that you aren't using "use strict" in your programs.
You'll avoid a lot of grief if you add "use strict;" to the top of each
of your program files.

> 
> #########################################################
> # GetDistrictDBInfoFromAxysGlobalWithMarket
> # Parameter
> #       String Market name
> # Returns 
> #       char* errmsg   // if empty then success
> #       char* AxysDBServer // District SQL server for the Market
> #       char* AxysDBDatabase // Database name of axysdb. (includes
> suffix)
> #########################################################
> sub GetDistrictDBInfoFromAxysGlobalWithMarket
> {
>         local ($market) = @_;

Use "my", not "local"

>         $market =~ s/ //g;
>         local ($sqlcmd,$msg,@info,$sqlserver);

use "my". "local" doesn't do what you  think it does...



>    $errorCode = $dbh->dbsqlexec;# || &InternalErrorPage;
>    if ($errorCode != 1)
>    {
>       &Log("GETAXYSDB ::BADMARKET:Error executing the following
> query:\n$sqlcmd\n",2);
>       return("BADMARKET:Error executing the following
> query:\n$sqlcmd\n",());
>    }
>    
>    if ($SybaseErrorFlag)
>    {
>       &Log("BADMARKET\n",3);
>           return("BADMARKET:$SybaseErrorMessage $SybaseMessage\n",());
>           
>    }

Here you should loop over dbresults() until it returns NO_MORE_RESULTS:

while($dbh->dbresults() != NO_MORE_RESULTS) {
    while(@data = $dbh->dbnextrow) {
        @info = @data;
    }
}

# NOW check to see that you have the appropriate @info data.

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
mpeppler@peppler.org                 http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or 
long term contract positions - http://www.mbay.net/~mpeppler/resume.html