$npx -y skills add github/awesome-copilot --skill migrating-oracle-to-postgres-stored-proceduresMigrates Oracle PL/SQL stored procedures to PostgreSQL PL/pgSQL. Translates Oracle-specific syntax, preserves method signatures and type-anchored parameters, leverages orafce where appropriate, and applies explicit collation mapping (COLLATE "C" only when appropriate, locale co
| 1 | # Migrating Stored Procedures from Oracle to PostgreSQL |
| 2 | |
| 3 | Translate Oracle PL/SQL stored procedures and functions to PostgreSQL PL/pgSQL equivalents. |
| 4 | |
| 5 | ## Workflow |
| 6 | |
| 7 | ``` |
| 8 | Progress: |
| 9 | - [ ] Step 1: Read the Oracle source procedure |
| 10 | - [ ] Step 2: Translate to PostgreSQL PL/pgSQL |
| 11 | - [ ] Step 3: Write the migrated procedure to Postgres output directory |
| 12 | ``` |
| 13 | |
| 14 | **Step 1: Read the Oracle source procedure** |
| 15 | |
| 16 | Read the Oracle stored procedure from `.github/oracle-to-postgres-migration/DDL/Oracle/Procedures and Functions/`. Consult the Oracle table/view definitions at `.github/oracle-to-postgres-migration/DDL/Oracle/Tables and Views/` for type resolution. |
| 17 | |
| 18 | **Step 2: Translate to PostgreSQL PL/pgSQL** |
| 19 | |
| 20 | Apply these translation rules: |
| 21 | |
| 22 | - Translate all Oracle-specific syntax to PostgreSQL equivalents. |
| 23 | - Preserve original functionality and control flow logic. |
| 24 | - Keep type-anchored input parameters (e.g., `PARAM_NAME IN table_name.column_name%TYPE`). |
| 25 | - Use explicit types (`NUMERIC`, `VARCHAR`, `INTEGER`) for output parameters passed to other procedures — do not type-anchor these. |
| 26 | - Do not alter method signatures. |
| 27 | - Do not prefix object names with schema names unless already present in the Oracle source. |
| 28 | - Leave exception handling and rollback logic unchanged. |
| 29 | - Do not generate `COMMENT` or `GRANT` statements. |
| 30 | - Apply collation intentionally when ordering text: |
| 31 | - Use `COLLATE "C"` only when Oracle-compatible binary ordering is required and no other sort order is specified. |
| 32 | - If Oracle used explicit linguistic sorting (for example `NLS_SORT = French`), map to an explicit PostgreSQL locale collation instead of `"C"`. |
| 33 | - Use `SELECT collname, collprovider, collcollate, collctype FROM pg_collation ORDER BY collname;` to discover collations in the target environment. |
| 34 | - Treat `UNION ALL` as a review checkpoint. Validate plan quality per branch and restructure if combined-branch planning causes regressions (for example, unexpected sequential scans on large tables). |
| 35 | - Leverage the `orafce` extension when it improves clarity or fidelity. |
| 36 | |
| 37 | Consult the PostgreSQL table/view definitions at `.github/oracle-to-postgres-migration/DDL/Postgres/Tables and Views/` for target schema details. |
| 38 | |
| 39 | **Step 3: Write the migrated procedure to Postgres output directory** |
| 40 | |
| 41 | Place each migrated procedure in its own file under `.github/oracle-to-postgres-migration/DDL/Postgres/Procedures and Functions/{PACKAGE_NAME_IF_APPLICABLE}/`. One procedure per file. |