in reply to Re: Perl db programming
in thread Perl db programming

I have changed my code as below:
my $sth = $dbh->prepare("exec sp_helptext ?"); $sth->execute($_[0]) || die ("cannot run sp"); while(my @data = $sth->fetchrow_array()) { print join(q{,}, @data) . "\n".$data[1]; } $sth->finish; $sth=undef;
when I print @data it seems to be giving me the number of lines in the SQL text. instead of the text itself. Please advise

Replies are listed 'Best First'.
Re^3: Perl db programming
by mje (Curate) on Feb 05, 2009 at 11:12 UTC
    when I print @data it seems to be giving me the number of lines in the SQL text. instead of the text itself.

    The code you show looks like it should work to me although I don't see why you added that "$data1" to the end of the print line. If you print an array in scalar context you get the number of elements in the array - that is just the way perl works. If you are saying the code you quote isn't working then show us the output and tell us what you expect.