LameNerd has asked for the wisdom of the Perl Monks concerning the following question:

Hail Monks,

I execute this snippet:
foreach my $invalidPackage ( @invalidPackages ) { my $compCmd = <<SQL; ALTER PACKAGE $dbuser.$invalidPackage COMPILE DEBUG BODY SQL print "Executing $compCmd"; $sth = $dbh->prepare($compCmd) or die $ARGV[0] . "[$compCmd] " . $dbh->errstr; $sth->execute(); while ( my @r = $sth->fetchrow_array ) { print ">>>@r"; } $sth->finish || die; }
Some of the packages have comipler errors in them.
The above snippet does not report these errors.
I thought that the errors would of been outputted when
I did
print ">>>@r";
I am wrong. What should I have done?

Thanks

Replies are listed 'Best First'.
Re: Get ouput from alter package statement.
by steves (Curate) on Feb 03, 2003 at 19:14 UTC

    I'm not sure if this applies exactly or not, but there's a DBI func method that I use with Oracle to get stored procedure output. The code for doing that looks like this:

    my $flag = 'foo'; $dbh->func(1000000, 'dbms_output_enable'); $sth = $dbh->prepare(" BEGIN do.pl(?); END; "); $sth->execute($flag); $result = $dbh->func('dbms_output_get'); print $result; $sth->finish();
Re: Get ouput from alter package statement.
by CountZero (Bishop) on Feb 03, 2003 at 19:26 UTC

    If you run that SQL-code directly through your database (Oracle?) what output do you get?

    Normally "execute" is used for SELECT type of SQL-statements only and "do" is used for non-SELECT-SQL-statements.

    Indeed, the "fetchrow"-instruction returns the resultset of the execute-instruction, which really only makes sense if there is a resultset to return.

    The "do"-instruction returns a value, which may indicate success or failure of your SQL-statement or the number of rows on which it operated (e.g. for a DELETE or UPDATE query). See your Database documentation for more info.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law