|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Problem with dbnextrow
Date: Apr 28 2003 3:04PM
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
|