Skip to content

Commit

Permalink
Extract custom type from a DECLARE section of a procedure to create
Browse files Browse the repository at this point in the history
it as user defined type. Thanks to naveenjul29 for the report.
  • Loading branch information
Gilles Darold committed Apr 1, 2021
1 parent 83eedc1 commit 4dfa073
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Ora2Pg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14347,6 +14347,13 @@ sub _convert_function
$func_return = " AS \$body\$\n";
}

# extract custom type declared in a stored procedure
my $create_type = '';
while ($fct_detail{declare} =~ s/\s+TYPE\s+([^\s]+)\s+IS\s+RECORD\s*\(([^;]+)\)\s*;//is)
{
$create_type .= "CREATE TYPE $1 AS ($2);\n";
}

my @at_ret_param = ();
my @at_ret_type = ();
my $at_suffix = '';
Expand Down Expand Up @@ -14392,7 +14399,7 @@ sub _convert_function
my $type = $fct_detail{type};
$type = 'FUNCTION' if (!$self->{pg_supports_procedure});

my $function = "\n${fct_warning}CREATE$self->{create_or_replace} $type $fname$at_suffix $fct_detail{args}";
my $function = "\n$create_type\n\n${fct_warning}CREATE$self->{create_or_replace} $type $fname$at_suffix $fct_detail{args}";
if (!$pname || !$self->{package_as_schema})
{
if ($self->{export_schema} && !$self->{schema})
Expand Down

0 comments on commit 4dfa073

Please sign in to comment.