I have a file containing a list of tables from an oracle schema.
I have to generate replication support for these tables, which is simple enough using the Oracle API.
The problem is coming when I try to generate the sql script from the file. It appears to be putting a newline at the end of the table names. Attached is the code to generate the script. I have tried to chomp() the table name once in the foreach loop, but that just returned a 1 in place of the table name.
#!/usr/bin/perl -w
use strict;
my $schema = shift(@ARGV);
my $infile = "./".$schema."_tables.out";
my $outfile = "./gen_rep_support_".$schema."_tables.sql";
my $table;
open (INFILE, "< $infile") or die "Couldn't open $infile: $!";
my @tables = <INFILE>;
close (INFILE);
open (OUTFILE, "> $outfile") or die "Couldn't open $outfile: $!";
foreach $table (@tables) {
print OUTFILE "BEGIN\n";
print OUTFILE " DBMS_REPCAT.CREATE_MASTER_REPOBJECT (\n";
print OUTFILE " gname => 'beastdb_mstr_grp',\n";
print OUTFILE " type => 'TABLE',\n";
print OUTFILE " oname => '$table',\n";
print OUTFILE " sname => '$schema',\n";
print OUTFILE " use_existing_object => TRUE,\n";
print OUTFILE " copy_rows => FALSE);\n";
print OUTFILE "END;\n";
print OUTFILE "/\n\n";
}
close (OUTFILE);
Thanks for any help.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.