Untitled
Submitted by reeses on Sat, 2003-08-02 03:09.
Lame perl of the day. Suck the sprocs out of a whoracle database and generate a crude call/dependency graph. This may be useful if you have scads of procs that call one another. It pulls the procs (as contained in user_source), and dumps an object suitable for passing to graphviz.
#!/usr/local/blackboard/apps/perl/bin/perl -w
use DBI;
my $dbh = DBI->connect('dbi:Oracle:sid', 'uid', 'passwd',
{RaiseError=>1, PrintError=>1, AutoCommit=>0})
or die "Could not connect!";
my $stProcs = $dbh->prepare( qq[select distinct name from user_source]);
$stProcs->execute;
%procNames = ();
my $recProc;
while ( ($recProc) = $stProcs->fetchrow_array ) {
$procNames{$recProc} = '1';
}
$stProcs->finish;
my $stLines = $dbh->prepare(qq[select name, text from user_source]);
$stLines->execute;
my $name;
my $text;
print "digraph graph_name {
";
while (($name, $text) = $stLines->fetchrow_array ) {
foreach (split ' ', $text) {
if ( defined $procNames{uc $_} && (uc $_ ne $name) ) {
print " " . lc $name . " -> $_;
";
}
}
}
$stLines->finish;
$dbh->disconnect;
print "}
";
|