Connecting Tech Pros Worldwide Help | Site Map

Perl with Sybase DBI - having problems in sp_helptext

Newbie
 
Join Date: Feb 2009
Posts: 1
#1: Feb 5 '09
Hi,
I am writing a perl scipt to get me the SQL text for a given stored procedure in Sybase. I have used the command sp_helptext <spname> to do this but am not able to extract the resultset. I am new to perl and this is my first script.

Code is as below:

Expand|Select|Wrap|Line Numbers
  1. $dbh = DBI->connect("dbi:Sybase:host=<host>;port=<port>", "user", "pwd");
  2.  
  3.         $dbh->do("use dbname");
  4.         my $sth = $dbh->prepare("exec sp_helptext ?");
  5.         $sth->execute($_[0]) || die ("cannot run sp");
  6.         while(my @data = $sth->fetchrow_array()) {
  7.            print join(q{,}, @data) . "\n".$data[1];
  8.         }
  9.         $sth->finish;
  10.         $sth=undef;
  11.  
I am getting a number when I print @data and null when I print $data[1]

I have been stuck with this for a while and not able to debug. Could some please help me. Many thanks in advance
Icecrack's Avatar
Expert
 
Join Date: Sep 2008
Location: Sydney, Australia
Posts: 173
#2: Feb 5 '09

re: Perl with Sybase DBI - having problems in sp_helptext


try to print
Expand|Select|Wrap|Line Numbers
  1. $data[0]
Reply


Similar Perl bytes