Automatic code conversion from Oracle PL/SQL to Postgres Pro PL/pgSQL is a work in progress in ora2pgpro and you have to do manual work. The Perl code used for automatic conversion is all stored in a specific Perl Module named Ora2Pgpro/PLSQL.pm
.
PLSQL_PGSQL
Enable/disable PL/SQL to PL/pgSQL conversion. Enabled by default.
NULL_EQUAL_EMPTY
ora2pgpro can replace all conditions with a test on NULL by a call to the
coalesce()
function to mimic the Oracle behavior where empty string are considered equal to NULL.(field1 IS NULL) is replaced by (coalesce(field1::text, '') = '') (field2 IS NOT NULL) is replaced by (field2 IS NOT NULL AND field2::text <> '')
You might want this replacement to be sure that your application will have the same behavior but if you have control on you application a better way is to change it to transform empty string into NULL because Postgres Pro makes the difference.
EMPTY_LOB_NULL
Force
empty_clob()
andempty_blob()
to be exported as NULL instead as empty string for the first one and\x
for the second. If NULL is allowed in your column, this might improve data export speed if you have a lot of empty lobs. Default is to preserve the exact data from Oracle.PACKAGE_AS_SCHEMA
If you do not want to export package as schema but as simple functions you might also want to replace all calls to
package_name.function_name
. If you disable thePACKAGE_AS_SCHEMA
directive, then ora2pgpro will replace all call topackage_name.function_name()
bypackage_name_function_name()
. Default is to use a schema to emulate package.The replacement will be done in all kind of DDL or code that is parsed by the PL/SQL to PL/pgSQL converter.
PLSQL_PGSQL
must be enabled or-p
used in command line.REWRITE_OUTER_JOIN
Enable this directive if the rewrite of Oracle native syntax (+) of
OUTER JOIN
is broken. This will force ora2pgpro to not rewrite such code, default is to try to rewrite simple form of the right outer join for the moment.UUID_FUNCTION
By default ora2pgpro will convert call to SYS_GUID() Oracle function with a call to uuid_generate_v4 from uuid-ossp extension. You can redefined it to use the gen_random_uuid function from pgcrypto extension by changing the function name. Default to uuid_generate_v4.
Note that when a RAW(16) and RAW(32) columns is found or that the RAW column has "SYS_GUID()" as default value ora2pgpro will automatically translate the type of the column into uuid which might be the right translation in most of the case. In this case data will be automatically migrated as Postgres Pro uuid data type provided by the "uuid-ossp" extension.
FUNCTION_STABLE
By default Oracle functions are marked as
STABLE
as they can not modify data unless when used in PL/SQL with variable assignment or as conditional expression. You can force ora2pgpro to create these function asVOLATILE
by disabling this configuration directive.COMMENT_COMMIT_ROLLBACK
By default call to COMMIT/ROLLBACK are kept untouched by ora2pgpro to force the user to review the logic of the function. Once it is fixed in Oracle source code or you want to comment these calls, enable the following directive.
COMMENT_SAVEPOINT
It is common to see SAVEPOINT calls inside PL/SQL procedure together with a ROLLBACK TO savepoint_name. When
COMMENT_COMMIT_ROLLBACK
is enabled, you may want to also comment SAVEPOINT calls, in this case enable it.STRING_CONSTANT_REGEXP
ora2pgpro replaces all string constants during the PL/SQL to PL/pgSQL translation, string constants are all text included between single quote. If you have a string placeholder used in dynamic call to queries, you can set a list of regexp to be temporary replaced to not break the parser. For example:
STRING_CONSTANT_REGEXP <placeholder value=".*">
The list of regexp must use the semicolon as separator.
ALTERNATIVE_QUOTING_REGEXP
To support the Alternative Quoting Mechanism ('Q' or 'q') for String Literals set the regexp with the text capture to use to extract the text part. For example with a variable declared as
c_sample VARCHAR2(100 CHAR) := q'{This doesn't work.}';
the regexp to use must be:
ALTERNATIVE_QUOTING_REGEXP q'{(.*)}'
ora2pgpro will use the
$$
delimiter, with the example the result will be:c_sample varchar(100) := $$This doesn't work.$$;
The value of this configuration directive can be a list of regexp separated by a semicolon. The capture part (in parenthesis) is mandatory in each regexp if you want to restore the string constant.
USE_ORAFCE
If you want to use functions defined in the orafce library and prevent ora2pgpro to translate calls to these functions, enable this directive.
By default ora2pgpro rewrite
add_month()
,add_year()
,date_trunc()
andto_char()
functions, but you may prefer to use the orafce version of these function that do not need any code transformation.INCLUDE_PACKAGES
Contains the comma-separated list of packages to allow to be exported. Used only with the
PACKAGE
export type. Only the last occurrence found in the file will be used.EXCLUDE_PACKAGES
Contains the comma-separated list of packages to exclude from export. Used only with the
PACKAGE
export type. Only the last occurrence found in the file will be used.POSTGRESPRO_ATX
If set to 1, enables export of autonomous transactions directly as Postgres Pro autonomous transactions.