Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

dumpview

by unixwzrd (Beadle)
on Feb 25, 2001 at 11:41 UTC ( [id://60738]=sourcecode: print w/replies, xml ) Need Help??
Category: Database
Author/Contact Info Mike Sullivan mps@discomsys.com
Description: Just a simple script to dump the source for an Oracle view.

The script reads the TEXT field from DBA_VIEWS, but first has to determine how long the field is since Oracle defines this column as a LONG.

Pretty simple quick hack, but people I work with have found it helpful.

Note: I'm using O/S authentication with a user who has DBA privs when I run this. If you're familiar with the DBI, you should be able to make appropriate changes to work for you.

#!/usr/bin/perl
#
# Written by: Mike Sullivan  (mps@discomsys.com)
#
# Distributed Computing Systems, LLC
#
# Feel free to hack on this and if you think of anything interesting
# to add to it, let me know and I'll try to add it into the master
# copy I have and post the mods for all to use.
#
# Enjoy.

use DBI;

$lda = DBI->connect("dbi:Oracle:$ENV{ORACLE_SID}", '/', '');

$lda->{LongTruncOk} = 1;

print "Enter viewname: ";
while(<STDIN>) {
   chomp($viewname = $_);
   $viewname = uc($viewname);
   $csr = $lda->prepare("select text_length
                              from dba_views
                              where view_name = \'$viewname\'");
   $csr->execute;
   ($text_length) = $csr->fetchrow_array;
   $lda->{LongReadLen} = $text_length;
   $csr = $lda->prepare("select text
                              from dba_views
                              where view_name = \'$viewname\'");
   $csr->execute;
   ($text) = $csr->fetchrow_array;

   print "Long text filed length: $text_length\n\n";
   print "$text\n";
   print "Enter viewname: ";
}

print "\n";
exit;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://60738]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found