Fix TABLE OF %ROWTYPE parameter in package (fixes #200) - #262
Conversation
ae13c4b to
d6d52c1Compared6d52c1 to
596a2baCompareThere was a problem hiding this comment.
Pull request overview
This PR fixes ruby-plsql’s handling of package-defined collection types declared as TABLE OF some_table%ROWTYPE, which previously caused ORA-00911: invalid character during temp table DDL generation. It adds detection of %ROWTYPE element types (via ALL_PLSQL_COLL_TYPES) and derives record fields from the referenced table/view columns, plus new specs covering both %ROWTYPE and RECORD workarounds.
Changes:
- Detect
ELEM_TYPE_NAMEvalues ending in%ROWTYPEfor package-defined collection element types and treat them asPL/SQL RECORDbacked by a TABLE/VIEW. - Resolve the referenced TABLE/VIEW via
ALL_OBJECTSand populate record field metadata from table/view columns. - Add specs for calling a package function with
TABLE OF %ROWTYPEandTABLE OF RECORDparameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/plsql/procedure.rb | Adds %ROWTYPE element-type detection and table/view-backed field expansion for package collection parameters. |
spec/plsql/procedure_spec.rb | Adds regression tests for %ROWTYPE collection parameters in packages and the existing RECORD workaround. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
600a660 to
d37e9d5CompareThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
On Oracle 18c+, get_element_definition queries ALL_PLSQL_COLL_TYPES (introduced in 18c) to resolve collection element types. For %ROWTYPE references, Oracle stores elem_type_name as "TABLE_NAME%ROWTYPE". The element was incorrectly treated as OBJECT, causing ensure_tmp_tables_created to embed the type name literally in DDL, producing ORA-00911. Detect the %ROWTYPE suffix in elem_type_name, strip it, verify the table via ALL_OBJECTS, then populate field definitions from table columns. On pre-18c databases (e.g. 11g), this code path is not reached because ALL_ARGUMENTS expands %ROWTYPE into individual fields at deeper data levels. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d37e9d5 to
703f0ecCompareThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
TABLE OF table%ROWTYPEcollection types defined in packages causingORA-00911: invalid characterwhen calling the functionALL_PLSQL_COLL_TYPES(introduced in 18c) to resolve collection element types. For%ROWTYPEreferences, Oracle returnsELEM_TYPE_NAMEas"TABLE_NAME%ROWTYPE". The element was incorrectly treated as OBJECT, causingensure_tmp_tables_createdto embed the type name with%ROWTYPEliterally in DDL%ROWTYPEsuffix inelem_type_name, strip it, verify the table viaALL_OBJECTS, then populate field definitions from table columnsALL_ARGUMENTSexpands%ROWTYPEinto individual fields at deeper data levelsFixes#200
Test plan
testworkflow passes (Oracle 23c Free)test_11gworkflow passes (Oracle 11g XE)TABLE OF %ROWTYPEparameter in packageTABLE OF RECORDparameter in package (workaround from Complex datatypes are not handled with ruby-plsql v 0.8.0 for oracle 19c #200, should continue to work)🤖 Generated with Claude Code