Upgrade to ora2pg 1.10. Backpatch to 7.3.X.

This commit is contained in:
Bruce Momjian 2003-01-07 22:15:56 +00:00
parent 30a800a0e9
commit ffab4fdf24
4 changed files with 39 additions and 16 deletions

View File

@ -38,6 +38,7 @@
by the schema name.
- Fix output of Oracle data extraction. It now require a call to the function
export_data().
2002 01 07 - Version 1.6
- Fix problem exporting NULL value. Thanks to Stephane Schildknecht.
@ -49,3 +50,17 @@
- Add column alias extraction on view. Thanks to Jean-Francois RIPOUTEAU
- Add PACKAGE extraction (type => DATA).
2002 06 04 - Version 1.9
- Fix a problem export data which fill NULL instead of 0 or empty string.
Thanks to Jan Kester.
- Add time with date when export data [ tochar('YYYY-MM-DD HH24:MI:SS') ].
Thanks to Paolo Mattioli.
2002 07 29 - Version 1.10
- Fix a problem with local settings regarding decimal separator (all ,
are changed to .) Thank to Jan Kester.
Thanks for all congratulation message and bug report I received.
Gilles DAROLD <gilles@darold.net>

View File

@ -17,8 +17,13 @@ package Ora2Pg;
use vars qw($VERSION $PSQL);
use Carp qw(confess);
use DBI;
use POSIX qw(locale_h);
$VERSION = "1.8";
#set locale to LC_NUMERIC C
setlocale(LC_NUMERIC,"C");
$VERSION = "1.9";
$PSQL = "psql";
=head1 NAME
@ -854,7 +859,7 @@ print STDERR "Add triggers definition...\n" if ($self->{debug});
# Escaping Single Quotes
#$trig->[4] =~ s/'/''/sg;
$sql_output .= "CREATE FUNCTION pg_fct_\L$trig->[0]\E () RETURNS TRIGGER AS '\n$trig->[4]\n' LANGUAGE 'plpgsql'\n\n";
$sql_output .= "CREATE FUNCTION pg_fct_\L$trig->[0]\E () RETURNS OPAQUE AS '\n$trig->[4]\n' LANGUAGE 'plpgsql'\n\n";
$sql_output .= "CREATE TRIGGER \L$trig->[0]\E\n\t$trig->[1] $trig->[2] ON \L$trig->[3]\E FOR EACH ROW\n\tEXECUTE PROCEDURE pg_fct_\L$trig->[0]\E();\n\n";
}
}
@ -1002,7 +1007,7 @@ print STDERR "Dumping table $table...\n" if ($self->{debug});
if ($self->{type} ne 'COPY') {
if ($tt[$i] =~ /(char|date|time|text)/) {
$row->[$i] =~ s/'/''/gs;
if ($row->[$i]) {
if ($row->[$i] ne '') {
$row->[$i] = "'$row->[$i]'";
} else {
$row->[$i] = 'NULL';
@ -1017,7 +1022,8 @@ print STDERR "Dumping table $table...\n" if ($self->{debug});
}
}
} else {
if (!$row->[$i]) {
$row->[$i] =~ s/,/./;
if ($row->[$i] eq '') {
$row->[$i] = 'NULL';
}
if ($self->{dbhdest}) {
@ -1042,7 +1048,10 @@ print STDERR "Dumping table $table...\n" if ($self->{debug});
}
}
} else {
if (!$row->[$i]) {
if ($tt[$i] !~ /(char|date|time|text)/) {
$row->[$i] =~ s/,/./;
}
if ($row->[$i] eq '') {
$row->[$i] = '\N';
}
if ($self->{dbhdest}) {
@ -1228,7 +1237,7 @@ sub _get_data
my $tmp = "SELECT ";
for my $k (0 .. $#{$name}) {
if ( $type->[$k] =~ /(date|time)/) {
$str .= "to_char($name->[$k], 'YYYY-MM-DD'),";
$str .= "to_char($name->[$k], 'YYYY-MM-DD HH24:MI:SS'),";
} else {
$str .= "$name->[$k],";
}
@ -1290,8 +1299,8 @@ sub _sql_type
'VARCHAR2' => 'varchar',
'NVARCHAR2' => 'varchar',
# The DATE data type is used to store the date and time information.
# Pg type timestamp should match all needs
'DATE' => 'timestamp',
# Pg type datetime should match all needs
'DATE' => 'datetime',
# Type LONG is like VARCHAR2 but with up to 2Gb.
# PG type text should match all needs or if you want you could use blob
'LONG' => 'text', # Character data of variable length

View File

@ -1,10 +1,6 @@
Add possible call to perl function for each field value exported
(data conversion on the fly before dump)
The following need your contribution :
- Fix problem regarding table/constraint output order.
The following need your help :
- SQL queries converter.
- PL/SQL code converter.

View File

@ -30,7 +30,7 @@ my $schema = new Ora2Pg (
user => $dbuser, # Database user
password => $dbpwd, # Database password
debug => 1, # Verbose mode
schema => 'APPS', # Extract only APPS schema
schema => 'ALICIA7', # Extract only APPS schema
type => 'TABLE', # Extract table
# type => 'PACKAGE', # Extract PACKAGE information
# type => 'DATA', # Extract data with output as INSERT statement
@ -46,6 +46,7 @@ my $schema = new Ora2Pg (
# tables => [('TX_DATA')], # simple indexes
# tables => [('NDW_BROWSER_ATTRIBUTES')], # view
# tables => [('TRIP_DATA')], # Foreign key
# tables => [('JO_TMP')], # Foreign key
# showtableid => 1, # Display only table indice during extraction
# min => 1, # Extract begin at indice 3
# max => 10, # Extract ended at indice 5
@ -56,7 +57,8 @@ my $schema = new Ora2Pg (
# Just export data of the following fields from table 's_txcot'
#$schema->modify_struct('s_txcot','dossier', 'rub', 'datapp');
# Function to use for extraction when type option is set to DATA or COPY
#### Function to use for extraction when type option is set to DATA or COPY
# Send exported data to a PostgreSQL database
#$schema->send_to_pgdb('dbi:Pg:dbname=template1;host=localhost;port=5432','test','test');
@ -64,7 +66,8 @@ my $schema = new Ora2Pg (
# If you set the send_to_pgdb() method the output is given to PG database. See above
#$schema->export_data("output.sql");
# Function to use ifor extraction with other type
#### Function to use for extraction of other type
# Create the POSTGRESQL representation of all objects in the database
$schema->export_schema("output.sql");