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: deridder at pcisys dot net
Subject: Returning duplicate names
Date: Sep 8 1999 12:28PM

In the following code I am monitoring connections.  The problem is when I
submit the sql in perl it only gives back one of the 'name' columns and
leaves out the sl.name.  I am assuming because they are the same name?  How
would I remedy this.  When I submit the sql from isql I get all values.

PS: The code line print "$dat{$key}   "; I use to put spaces between the
values.  How do I check when there is a new row of values returned.  I don't
want to put spaces after the last value on each row.  

TIA
steve deridder

use Sybase::CTlib;
$uid = 'dbo'; $pwd = 'dbo'; $srv = 'SRVR';
$sqlstmt = 'select   sp.spid, sl.name,
            sd.name, sp.cmd
            from  master..syslogins sl,
               master..sysprocesses sp,
               master..sysdatabases sd
            where sd.name in ("UTEST_CAT", "UTEST_ADMIN")
            and      sd.dbid = sp.dbid
            and      sp.suid = sl.suid
            order by sp.spid';


$X = Sybase::CTlib->ct_connect($uid, $pwd, $srv);
$X->ct_sql("use master");
$X->ct_execute($sqlstmt);
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
     next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
             $restype == CS_CMD_SUCCEED);
     while(%dat = $X->ct_fetch(CS_TRUE)) {
        foreach $key(keys %dat) {
                print "$dat{$key}   ";
        }
        print "\n\n";
     }
}
print "End of Results Sets\n" if($rc == CS_END_RESULTS);
print "Error!\n" if($rc ==
CS_FAIL);

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/