@@ -17,8 +17,13 @@ package Ora2Pg;
17
17
use vars qw( $VERSION $PSQL) ;
18
18
use Carp qw( confess) ;
19
19
use DBI;
20
+ use POSIX qw( locale_h) ;
20
21
21
- $VERSION = " 1.8" ;
22
+ # set locale to LC_NUMERIC C
23
+ setlocale(LC_NUMERIC," C" );
24
+
25
+
26
+ $VERSION = " 1.9" ;
22
27
$PSQL = " psql" ;
23
28
24
29
=head1 NAME
@@ -854,7 +859,7 @@ print STDERR "Add triggers definition...\n" if ($self->{debug});
854
859
# Escaping Single Quotes
855
860
# $trig->[4] =~ s/'/''/sg;
856
861
857
- $sql_output .= " CREATE FUNCTION pg_fct_\L $trig ->[0]\E () RETURNS TRIGGER AS '\n $trig ->[4]\n ' LANGUAGE 'plpgsql'\n\n " ;
862
+ $sql_output .= " CREATE FUNCTION pg_fct_\L $trig ->[0]\E () RETURNS OPAQUE AS '\n $trig ->[4]\n ' LANGUAGE 'plpgsql'\n\n " ;
858
863
$sql_output .= " CREATE TRIGGER \L $trig ->[0]\E\n\t $trig ->[1] $trig ->[2] ON \L $trig ->[3]\E FOR EACH ROW\n\t EXECUTE PROCEDURE pg_fct_\L $trig ->[0]\E ();\n\n " ;
859
864
}
860
865
}
@@ -1002,7 +1007,7 @@ print STDERR "Dumping table $table...\n" if ($self->{debug});
1002
1007
if ($self -> {type } ne ' COPY' ) {
1003
1008
if ($tt [$i ] =~ / (char|date|time|text)/ ) {
1004
1009
$row -> [$i ] =~ s / '/ ''/ gs ;
1005
- if ($row -> [$i ]) {
1010
+ if ($row -> [$i ] ne ' ' ) {
1006
1011
$row -> [$i ] = " '$row ->[$i ]'" ;
1007
1012
} else {
1008
1013
$row -> [$i ] = ' NULL' ;
@@ -1017,7 +1022,8 @@ print STDERR "Dumping table $table...\n" if ($self->{debug});
1017
1022
}
1018
1023
}
1019
1024
} else {
1020
- if (!$row -> [$i ]) {
1025
+ $row -> [$i ] =~ s / ,/ ./ ;
1026
+ if ($row -> [$i ] eq ' ' ) {
1021
1027
$row -> [$i ] = ' NULL' ;
1022
1028
}
1023
1029
if ($self -> {dbhdest }) {
@@ -1042,7 +1048,10 @@ print STDERR "Dumping table $table...\n" if ($self->{debug});
1042
1048
}
1043
1049
}
1044
1050
} else {
1045
- if (!$row -> [$i ]) {
1051
+ if ($tt [$i ] !~ / (char|date|time|text)/ ) {
1052
+ $row -> [$i ] =~ s / ,/ ./ ;
1053
+ }
1054
+ if ($row -> [$i ] eq ' ' ) {
1046
1055
$row -> [$i ] = ' \N' ;
1047
1056
}
1048
1057
if ($self -> {dbhdest }) {
@@ -1228,7 +1237,7 @@ sub _get_data
1228
1237
my $tmp = " SELECT " ;
1229
1238
for my $k (0 .. $# {$name }) {
1230
1239
if ( $type -> [$k ] =~ / (date|time)/ ) {
1231
- $str .= " to_char($name ->[$k ], 'YYYY-MM-DD')," ;
1240
+ $str .= " to_char($name ->[$k ], 'YYYY-MM-DD HH24:MI:SS ')," ;
1232
1241
} else {
1233
1242
$str .= " $name ->[$k ]," ;
1234
1243
}
@@ -1290,8 +1299,8 @@ sub _sql_type
1290
1299
' VARCHAR2' => ' varchar' ,
1291
1300
' NVARCHAR2' => ' varchar' ,
1292
1301
# The DATE data type is used to store the date and time information.
1293
- # Pg type timestamp should match all needs
1294
- ' DATE' => ' timestamp ' ,
1302
+ # Pg type datetime should match all needs
1303
+ ' DATE' => ' datetime ' ,
1295
1304
# Type LONG is like VARCHAR2 but with up to 2Gb.
1296
1305
# PG type text should match all needs or if you want you could use blob
1297
1306
' LONG' => ' text' , # Character data of variable length
0 commit comments