rbc has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I don't know what I am doing wrong here.
I think the white board marker fumes are giving
me a mighty buzz because I cannot figure this
problem I am having out.
The below script works fine. It pulls the source code
out of a Oracle database for FUNCTIONS, PROCEDURES,
PACKAGES and PACKAGE BODYS
so that I could get the source code for triggers.
And here's the trigger getting script which does not
seem to get any trigger source!
... the only output I get is this ...
I must be missing something.
Your help is appreicated!
I don't know what I am doing wrong here.
I think the white board marker fumes are giving
me a mighty buzz because I cannot figure this
problem I am having out.
The below script works fine. It pulls the source code
out of a Oracle database for FUNCTIONS, PROCEDURES,
PACKAGES and PACKAGE BODYS
... I thought that I would modify this script#!/usr/bin/perl -w use DBI; $NAME = shift; $TYPE = shift; $dbname = 'prod'; $dbuser = 'prod'; $dbpass = 'prod'; $dbd = 'Oracle'; $dbh = DBI->connect ( $dbname, $dbuser, $dbpass, $dbd); if (!$dbh) { print "Error conecting to DB; $DBI::errstr\n"; } my $sql = <<SQL; select text from user_source where name = ? and type = ? SQL my $sth = $dbh->prepare($sql) || die $dbh->errstr; print "CREATE or REPLACE\n"; $sth->execute( $NAME, $TYPE ); while ( my @r = $sth->fetchrow_array ) { print @r; } print "/\n"; print "show errors\n"; $sth->finish || die; $dbh->disconnect;
so that I could get the source code for triggers.
And here's the trigger getting script which does not
seem to get any trigger source!
When I run this above script like so ...#!/usr/bin/perl -w use DBI; use Data::Dumper; $NAME = shift; $dbname = 'prod'; $dbuser = 'prod'; $dbpass = 'prod'; $dbd = 'Oracle'; $dbh = DBI->connect ( $dbname, $dbuser, $dbpass, $dbd); if (!$dbh) { print "Error conecting to DB; $DBI::errstr\n"; } my $sql = <<SQL; select description, trigger_body from user_triggers where trigger_name = ? SQL #print $sql; my $sth = $dbh->prepare($sql) || die $dbh->errstr; print "CREATE or REPLACE $NAME\n"; $sth->execute( $NAME ); while ( my @r = $sth->fetchrow_array ) { print @r; } print "/\n"; print "show errors\n"; $sth->finish || die; $dbh->disconnect;
$ ./getTrigger.pl MY_TRIGGER
... the only output I get is this ...
CREATE or REPLACE MY_TRIGGER / show errorsAnd there is a trigger named MY_TRIGGER in my DB. :(
I must be missing something.
Your help is appreicated!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DBI and getting trigger info
by runrig (Abbot) on Dec 18, 2002 at 23:29 UTC | |
by rbc (Curate) on Dec 19, 2002 at 00:00 UTC | |
by pfaut (Priest) on Dec 19, 2002 at 00:06 UTC | |
Re: DBI and getting trigger info
by pfaut (Priest) on Dec 18, 2002 at 23:25 UTC |
Back to
Seekers of Perl Wisdom