Handle overloaded Oracle functions in Aurora PostgreSQL-Compatible
Created by Sumana Yanamandra (AWS)
Environment: PoC or pilot | Source: Oracle Database | Target: Aurora PostgreSQL-Compatible |
R Type: Replatform | Workload: Oracle | Technologies: Databases; Migration |
AWS services: Amazon Aurora |
Summary
The code you migrate from an on-premises Oracle database to Amazon Aurora PostgreSQL-Compatible Edition might include overloaded functions. These functions have the same definition—that is, the same function name and the same number and data type of input (IN
) parameters—but the data type or the number of output (OUT
) parameters might differ.
These parameter mismatches can cause problems in PostgreSQL, because it’s difficult to determine which function to run. This pattern illustrates how to handle overloaded functions when you migrate your database code to Aurora PostgreSQL-Compatible.
Prerequisites and limitations
Prerequisites
An Oracle database instance as your source database
An Aurora PostgreSQL-Compatible DB instance as your target database (see instructions in the Aurora documentation)
Product versions
Oracle Database 9i or later
Oracle SQL Developer version 18.4.0.376
pgAdmin 4 client
Aurora PostgreSQL-Compatible version 11 or later (see Identifying versions of Amazon Aurora PostgreSQL in the Aurora documentation)
Tools
AWS services
Amazon Aurora PostgreSQL-Compatible Edition is a fully managed, ACID-compliant relational database engine that helps you set up, operate, and scale PostgreSQL deployments.
Other tools
Oracle SQL Developer
is a free, integrated development environment for working with SQL in Oracle databases in both traditional and cloud deployments. pgAdmin
is an open-source management tool for PostgreSQL. It provides a graphical interface that helps you create, maintain, and use database objects.
Epics
Task | Description | Skills required |
---|---|---|
Create a function in PostgreSQL that has one input parameter and one output parameter. | The following example illustrates a function named
| Data engineer, Aurora PostgreSQL-Compatible |
Run the function in PostgreSQL. | Run the function that you created in the previous step.
It should display the following output.
| Data engineer, Aurora PostgreSQL-Compatible |
Task | Description | Skills required |
---|---|---|
Use the same function name to create an overloaded function in PostgreSQL. | Create an overloaded function in Aurora PostgreSQL-Compatible that uses the same function name as your previous function. The following example is also named
| Data engineer, Aurora PostgreSQL-Compatible |
Run the function in PostgreSQL. | When you run this function, it fails with the following error message.
This happens because Aurora PostgreSQL-Compatible doesn’t support function overloading directly. It can’t identify which function to run, because the number of output parameters is different in the second version of the function, although the input parameters are the same. | Data engineer, Aurora PostgreSQL-Compatible |
Task | Description | Skills required |
---|---|---|
Add INOUT to the first output parameter. | As a workaround, modify the function code by representing the first output parameter as
| Data engineer, Aurora PostgreSQL-Compatible |
Run the revised function. | Run the function that you updated by using the following query. You pass a null value as the second argument of this function, because you declared this parameter as
The function is now created successfully.
| Data engineer, Aurora PostgreSQL-Compatible |
Validate the results. | Verify that the code with the overloaded function was converted successfully. | Data engineer, Aurora PostgreSQL-Compatible |
Related resources
Working with Amazon Aurora PostgreSQL (Aurora documentation)
Function overloading in Oracle
(Oracle documentation) Function overloading in PostgreSQL
(PostgreSQL documentation)