]> granicus.if.org Git - postgresql/commitdiff
Upgrade to ora2pg 1.10. Backpatch to 7.3.X.
authorBruce Momjian <bruce@momjian.us>
Tue, 7 Jan 2003 22:15:56 +0000 (22:15 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 7 Jan 2003 22:15:56 +0000 (22:15 +0000)
contrib/oracle/CHANGES
contrib/oracle/Ora2Pg.pm
contrib/oracle/TODO
contrib/oracle/ora2pg.pl

index 34851ecb659691d06b67cdf417ccaddfe57dfd7e..b1d27ad2509ee926a7a3e1df5ae572bb68e05525 100644 (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.
 
        - 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>
+
index a11d8365505bd62e562715ebc91e91ccf923c930..b93423cc5cf98eb472271d4bda24c8cf417ca6cc 100644 (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
index c9f43921704cc54ab6cef1af17a7b4ba149bf1d9..da0179e4718e7b5432dfefd97993819a788ae1da 100644 (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.
 
index 3a15fb7bed419fa1e443f56cb77ff454fcafc26a..80c97c38ccdea65dd2f32cad85961e4754874274 100755 (executable)
@@ -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");