Skip to content

feat: add INSERT statement parsing with host variable bindings#2846

Open
allieseb wants to merge 9 commits intoTypeCobolTeam:developfrom
allieseb:pr/insert-statement
Open

feat: add INSERT statement parsing with host variable bindings#2846
allieseb wants to merge 9 commits intoTypeCobolTeam:developfrom
allieseb:pr/insert-statement

Conversation

@allieseb
Copy link
Copy Markdown

@allieseb allieseb commented Apr 8, 2026

Summary

  • Add structured parsing for SQL INSERT statements in embedded COBOL SQL blocks
  • Introduce shared HostVariableBinding class for column-to-host-variable mapping (reused by later DML PRs)
  • New InsertStatement CodeElement with TableName, Columns, HostVariables, HasSubselect properties
  • Full infrastructure: ANTLR grammar rule, CUP terminal/production, visitor, builder, dispatcher, listener

Depends on #2845

Test plan

  • New test ExecSqlWithInsertStatement.rdz.cbl with 4 INSERT scenarios (VALUES, schema-qualified, subselect, no column list)
  • Updated ExecSqlWithUnsupportedStatement expected output (INSERT no longer unsupported)
  • All 63 existing tests pass (26 skipped — perf/incremental)

🤖 Generated with Claude Code

allieseb and others added 9 commits April 7, 2026 11:01
…very

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… infrastructure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New test file with INSERT, UPDATE, DELETE, DECLARE CURSOR, OPEN, FETCH, CLOSE
- All 7 unsupported statements parse without errors (catch-all rule works)
- Updated expected results for ExecInDataDivision and ExecSqlWithCommit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The unsupportedSqlStatement rule now matches any SQL tokens until END-EXEC
instead of a closed list of 7 keywords. This handles all current and future
SQL statements (GRANT, REVOKE, MERGE, CALL, CREATE INDEX, etc.) without
requiring grammar updates for each new unsupported keyword.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ent set

Replace the arbitrary SQL keyword list in unsupportedSqlStatement with a
systematic set derived from the DB2 z/OS SQL Reference. The new
unsupportedSqlKeyword rule lists all 26 statement-starting keywords that
don't have a dedicated parser rule, with documentation of which SQL
statements they cover. This eliminates the need to guess which keywords
to add — when a new dedicated rule is created, its keyword is simply
removed from this list.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add structured parsing for SQL INSERT statements in embedded COBOL SQL.
Introduces HostVariableBinding shared class for column-to-variable mapping.

- New InsertStatement CodeElement with TableName, Columns, HostVariables, HasSubselect
- New Insert AST node (GenericNode<InsertStatement>)
- ANTLR grammar rule: insertStatement with insertColumnList
- Remove SQL_INSERT from unsupportedSqlStatement catch-all
- Full infrastructure: enum, visitor, CUP terminal/production, builder, dispatcher, listener
- SqlCodeElementBuilder.CreateInsertStatement() with helper methods
- Test: 4 INSERT scenarios (VALUES, schema-qualified, subselect, no column list)
- Updated UnsupportedSqlStatement test expected output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@allieseb allieseb force-pushed the pr/insert-statement branch from e1d4156 to 2bdcf9c Compare April 8, 2026 12:12
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.

1 participant