Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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
#!/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;
... I thought that I would modify this script
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!
#!/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;
When I run this above script like so ...
$ ./getTrigger.pl MY_TRIGGER

... the only output I get is this ...
CREATE or REPLACE MY_TRIGGER
/
show errors
And there is a trigger named MY_TRIGGER in my DB. :(
I must be missing something.
Your help is appreicated!

In reply to DBI and getting trigger info by rbc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (6)
    As of 2015-07-03 17:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (55 votes), past polls