X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=dump_oracle_table_for_pg;fp=dump_oracle_table_for_pg;h=f8969e9137d68139cd4d97038f6dca09b892cb45;hp=93a2312f5c6e65dcf38a335c35ebe68b3ecd9071;hb=1480d6fc7956765eafe92cf49868f1fcf720c390;hpb=a10d65c8040afbaa527ab930802222663d5be87e diff --git a/dump_oracle_table_for_pg b/dump_oracle_table_for_pg index 93a2312..f8969e9 100755 --- a/dump_oracle_table_for_pg +++ b/dump_oracle_table_for_pg @@ -129,7 +129,7 @@ sub normalize_value_for_tsv { sub get_columns { my $table = shift; my $sth_cols = $dbh->prepare(' - SELECT column_name, data_type, data_precision, data_scale, nullable + SELECT column_name, data_type, data_precision, data_scale, data_length, nullable FROM user_tab_columns WHERE table_name = ? ORDER BY column_id '); $sth_cols->execute($table); @@ -147,11 +147,13 @@ sub get_pg_column_type { } elsif ($column_def->{DATA_TYPE} eq 'DATE') { $type = 'TIMESTAMP'; } elsif ($column_def->{DATA_TYPE} eq 'NUMBER') { - if ($column_def->{DATA_SCALE} == 0) { + if (!defined($column_def->{DATA_SCALE}) || $column_def->{DATA_SCALE} == 0) { $type = 'INTEGER'; } else { $type = "NUMERIC($column_def->{DATA_PRECISION},$column_def->{DATA_SCALE})"; } + } elsif ($column_def->{DATA_TYPE} eq 'CHAR') { + $type = "CHAR($column_def->{DATA_LENGTH})"; } if (defined $type) { $type .= " NOT NULL" if $column_def->{NULLABLE} eq 'N';