I'm working on a script, which redeployes packages, functions, procedures etc. from one db to the other. I have a problem with a package(spec and body at once). When I call the script below with arguments:
-from DB1 -to DB2 -owner USER1 -type PACKAGE -name PACK1
the spec is wrong as it contains spec and body. The body is ok. How can I change it, so, that it will redeploy spec and body correct?
#!/usr/bin/perl
use DBI;
use Text::Trim qw(trim);
use Getopt::Long;
use strict;
use warnings;
my $name = '';
my $db_from;
my $db_to;
my $owner = 'OWNER';
my $table;
my $type;
GetOptions ("from=s" => \$db_from,
"to=s" => \$db_to,
"owner=s" => \$owner,
"type=s" => \$type,
"name=s" => \$name );
my $dbh = DBI->connect("dbi:Oracle:$db_from",'ADMIN','pw');
$dbh->{LongReadLen} = 6024 * 1024;
$dbh->{LongTruncOk} = 1;
my $SEL = "SELECT DBMS_METADATA.GET_DDL('$type', '$name', '$owner') FROM DUAL";
my $sth = $dbh->prepare( $SEL ) or die "Can't prepare statement: $DBI::errstr";
my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr";
my $code = $sth->fetchrow();
my $dbh_to = DBI->connect("dbi:Oracle:$db_to",'ADMIN','pw');
$dbh_to->{LongReadLen} = 6024 * 1024;
$dbh_to->{LongTruncOk} = 1;
print $code;
$dbh_to->do($code);
$sth->finish;
$dbh->disconnect;
$dbh_to->disconnect;