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: "Warren Pollans" <wpollans at verio dot net>
Subject: RE: trying to execute "sp_columns"
Date: Feb 28 2001 8:37PM

I modified your scriptlet so that I could run sp_columns against one of our
user tables - works just fine!.  I was going through a home-grown module
that accessed the Sybase::DBlib module.  The problem has to be in our
modules.

Thanks for the help.

Regards,

Warren

-----Original Message-----
From: owner-SYBPERL-L@list.cren.net
[mailto:owner-SYBPERL-L@list.cren.net]On Behalf Of Michael Peppler
Sent: Wednesday, February 28, 2001 2:23 PM
To: SybPerl Discussion List
Subject: Re: trying to execute "sp_columns"


Warren Pollans writes:
 > Hello,
 >
 > I would like to execute "sp_columns tablename" for some table.  I've
tried
 > to do it the same way I execute a "select ..." query, but it doesn't
work.
 >
 > 	I can connect to the DB OK.
 >
 > 	$dbh->dbcmd($q); is OK
 >
 > 	$dbh->dbsqlexec; is OK
 >
 > but
 >
 > 	$dbh->dbresults; FAILS
 >
 > What's the correct way to do this?
 >
 >
 > I'm trying to write a web-based utility (cgi) that will take a tablename
as
 > an argument and return assorted information about the table.

Check the error messages from the server - you may be trying to get
data for a table that is not in the current database.

The code below works correctly:

#!/usr/local/bin/perl -w

use strict;
use Sybase::DBlib;

my $dbh = new Sybase::DBlib 'sa', '', '';
$dbh->dbcmd("sp_columns 'sysusers'");
$dbh->dbsqlexec;
while($dbh->dbresults != NO_MORE_RESULTS) {
    while(my @d = $dbh->dbnextrow) {
	print "@d\n";
    }
}


Michael
--
Michael Peppler - Data Migrations Inc. - mpeppler@peppler.org
http://www.mbay.net/~mpeppler - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com