|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: trying to execute "sp_columns"
Date: Feb 28 2001 7:23PM
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
|