Skip to content

Fix TABLE OF %ROWTYPE parameter in package (fixes #200)#262

Merged
yahonda merged 1 commit intorsim:masterfrom
yahonda:fix-rowtype-tmp-table
Apr 13, 2026
Merged

Fix TABLE OF %ROWTYPE parameter in package (fixes #200)#262
yahonda merged 1 commit intorsim:masterfrom
yahonda:fix-rowtype-tmp-table

Conversation

@yahonda
Copy link
Copy Markdown
Collaborator

@yahonda yahonda commented Apr 13, 2026

Summary

  • Fix TABLE OF table%ROWTYPE collection types defined in packages causing ORA-00911: invalid character when calling the function
  • On Oracle 18c+, the existing code queries ALL_PLSQL_COLL_TYPES (introduced in 18c) to resolve collection element types. For %ROWTYPE references, Oracle returns ELEM_TYPE_NAME as "TABLE_NAME%ROWTYPE". The element was incorrectly treated as OBJECT, causing ensure_tmp_tables_created to embed the type name with %ROWTYPE literally in DDL
  • Detect %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

Fixes #200

Test plan

🤖 Generated with Claude Code

@yahonda yahonda marked this pull request as ready for review April 13, 2026 06:17
@yahonda yahonda marked this pull request as draft April 13, 2026 06:17
@yahonda yahonda force-pushed the fix-rowtype-tmp-table branch 7 times, most recently from ae13c4b to d6d52c1 Compare April 13, 2026 07:06
@yahonda yahonda marked this pull request as ready for review April 13, 2026 07:09
@yahonda yahonda requested a review from Copilot April 13, 2026 07:24
@yahonda yahonda force-pushed the fix-rowtype-tmp-table branch from d6d52c1 to 596a2ba Compare April 13, 2026 07:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_NAME values ending in %ROWTYPE for package-defined collection element types and treat them as PL/SQL RECORD backed by a TABLE/VIEW.
  • Resolve the referenced TABLE/VIEW via ALL_OBJECTS and populate record field metadata from table/view columns.
  • Add specs for calling a package function with TABLE OF %ROWTYPE and TABLE OF RECORD parameters.

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.

@yahonda yahonda force-pushed the fix-rowtype-tmp-table branch 3 times, most recently from 600a660 to d37e9d5 Compare April 13, 2026 07:43
@yahonda yahonda requested a review from Copilot April 13, 2026 07:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yahonda yahonda merged commit 2adf627 into rsim:master Apr 13, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complex datatypes are not handled with ruby-plsql v 0.8.0 for oracle 19c

2 participants