SPUG:Problems getting rows from sybase db

Jonathan Gardner jgardn at alumni.washington.edu
Mon Apr 28 16:19:19 CDT 2003


On Monday 28 April 2003 13:43, Brittingham, John wrote:
> Having problem get dbnextrow to reurn the row, eventhough dbresults returns
> 1
>
<snip code>

Couple of friendly comments that have nothing to do with your question (and 
thus may utterly be disregarded with prejudice):

1) Have you looked into using DBI? I know from experience that going from 
Sybase to Oracle to PostgreSQL was a lot easier because DBI didn't change 
between them. I can't speak for your situation, so you may have a very good 
reason for using what you are using.

1.5) You don't need to type so much because the variables work like shell in 
quotes.

print("Data base Info ".$NavDBUsername." ".$NavDBPassword." ".$NavDBServer." 
".$AppName."\n");

is shorter and possibly morel legible when written as:

print("Data base Info $NavDBUsername $NavDBPassword $NavDBServer $AppName\n");

2) For large bits of text. consider using here docs instead of quotes to 
increase legibility. A here doc would work like this:

$dbh->dbcmd(<<SQL);
select NSS.name, NPDB.name from PFWUtil..NavAreaPhysicalDbSqlServer NAPDBSS,
        PFWUtil..NavAreaLogicalDb NALDB, PFWUtil..NavLogicalDb NLDB, 
PFWUtil..NavPhysicalDb NPDB,
        PFWUtil..NavSqlServer NSS, PFWUtil..NavArea NA where  NPDB.oid = 
NAPDBSS.oidPhysicalDb
        and  NSS.oid = NAPDBSS.oidSqlServer  and  NLDB.oid = 
NALDB.oidLogicalDb
        and  NALDB.oidAreaPhysicalDbSqlServer = NAPDBSS.oid and  NALDB.oidArea 
= NA.oid
        and  NLDB.name = 'AXYSDB' and lower(NA.name) like lower('Western%')
SQL

3) And since I don't save much by saving lines because I use a here doc, I 
would rewrite that statement like this:

$dbh->dbcmd(<<SQL);
select NSS.name
	, NPDB.name
from PFWUtil..NavAreaPhysicalDbSqlServer NAPDBSS
	, PFWUtil..NavAreaLogicalDb NALDB
	, PFWUtil..NavLogicalDb NLDB
	, PFWUtil..NavPhysicalDb NPDB
	, PFWUtil..NavSqlServer NSS
	, PFWUtil..NavArea NA
where  NPDB.oid = NAPDBSS.oidPhysicalDb
        and  NSS.oid = NAPDBSS.oidSqlServer
	and  NLDB.oid = NALDB.oidLogicalDb
        and  NALDB.oidAreaPhysicalDbSqlServer = NAPDBSS.oid
	and  NALDB.oidArea = NA.oid
        and  NLDB.name = 'AXYSDB'
	and lower(NA.name) like lower('Western%')
SQL

This makes it easier to add and remove columns/tables/conditions.

-- 
Jonathan M. Gardner
Smooth Corporation - Perl Programmer
jgardner at smoothcorp.com - (425) 460-4780
Live Free, Use Linux!



More information about the spug-list mailing list