| version 1.8, 2004/01/23 13:54:52 |
version 1.9, 2004/01/23 14:09:08 |
|
|
| #!/usr/bin/perl |
#!/usr/bin/perl |
| |
|
| # $Platon: scripts/perl/oracle/oracledump.pl,v 1.7 2004/01/22 22:01:37 nepto Exp $ |
# $Platon: scripts/perl/oracle/oracledump.pl,v 1.8 2004/01/23 13:54:52 nepto Exp $ |
| |
|
| use strict; |
use strict; |
| |
|
| Line 369 foreach $table (@opt_tables) |
|
| Line 369 foreach $table (@opt_tables) |
|
| { |
{ |
| my @column_types; |
my @column_types; |
| my @row; |
my @row; |
| |
my $table_out; |
| |
|
| |
$table_out = $table; |
| |
$table_out = lc $table_out if defined $opt_mysql_compliant_dump; |
| |
$table = uc $table; |
| |
|
| |
|
| ## Print table structure |
## Print table structure |
| |
|
| Line 380 foreach $table (@opt_tables) |
|
| Line 386 foreach $table (@opt_tables) |
|
| print <<MARK; |
print <<MARK; |
| |
|
| $CM |
$CM |
| $CM Table structure for table '$table' |
$CM Table structure for table '$table_out' |
| $CM |
$CM |
| MARK |
MARK |
| ## Print drop table if requested |
## Print drop table if requested |
| |
|
| if (defined $opt_add_drop_table) |
if ( defined $opt_add_drop_table ) |
| { |
{ |
| print <<MARK; |
if ( defined $opt_mysql_compliant_dump ) { |
| DROP TABLE $table; |
print <<MARK; |
| |
DROP TABLE IF EXISTS $table_out; |
| MARK |
MARK |
| } |
} else { |
| |
print <<MARK; |
| |
DROP TABLE $table_out; |
| |
MARK |
| |
} |
| |
} |
| |
|
| ## Print create table |
## Print create table |
| |
|
| print <<MARK; |
print <<MARK; |
| CREATE TABLE $table ( |
CREATE TABLE $table_out ( |
| MARK |
MARK |
| |
|
| } |
} |
|
|
| FROM user_tab_columns |
FROM user_tab_columns |
| WHERE table_name = ?"); |
WHERE table_name = ?"); |
| |
|
| $sth->execute(uc($table)) || die $DBI::errstr; |
$sth->execute($table) || die $DBI::errstr; |
| |
|
| my $c = 0; |
my $c = 0; |
| while (@row = $sth->fetchrow_array()) |
while (@row = $sth->fetchrow_array()) |
|
|
| print <<MARK; |
print <<MARK; |
| |
|
| $CM |
$CM |
| $CM Dumping data for table '$table' |
$CM Dumping data for table '$table_out' |
| @{[ (scalar @opt_where > 0) |
@{[ (scalar @opt_where > 0) |
| ? "$CM WHERE: " . join(' AND ', @opt_where) . "\n$CM\n" |
? "$CM WHERE: " . join(' AND ', @opt_where) . "\n$CM\n" |
| : "$CM\n" ]} |
: "$CM\n" ]} |
|
|
| FROM user_tab_columns |
FROM user_tab_columns |
| WHERE table_name = ?"); |
WHERE table_name = ?"); |
| |
|
| $sth->execute(uc($table)) || die $DBI::errstr; |
$sth->execute($table) || die $DBI::errstr; |
| |
|
| while (@row = $sth->fetchrow_array()) |
while (@row = $sth->fetchrow_array()) |
| { |
{ |
|
|
| while (@row = $sth->fetchrow_array()) |
while (@row = $sth->fetchrow_array()) |
| { |
{ |
| print <<MARK; |
print <<MARK; |
| INSERT INTO $table (@{[ join(', ', @column_names) ]}) |
INSERT INTO $table_out (@{[ join(', ', @column_names) ]}) |
| VALUES (@{[ join(',', map(escape_data($column_types[$_], $row[$_]), 0..$#column_names)) ]}); |
VALUES (@{[ join(',', map(escape_data($column_types[$_], $row[$_]), 0..$#column_names)) ]}); |
| MARK |
MARK |
| } |
} |