[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HR9ES4XVSFS0XBQNQT1XM6":3,"skill-same:01M6HR9ES4XVSFS0XBQNQT1XM6":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":47,"ownerHtmlUrl":48,"ownerBlogUrl":49,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M6HR9ES4XVSFS0XBQNQT1XM6","migrate-oracle-sp-trigger-to-scalardb",null,"Generates ScalarDB Java application code from Oracle PL\u002FSQL stored procedures, functions, packages, and triggers. Produces Java Transaction API implementations plus a summary migration report.","wfukatsu\u002Fnexus-architect","wfukatsu","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F11712747?v=4","01M6HR128TEJY1WD0C36TDQD7S","Wataru Fukatsu","01M6HR12D55WNY36YSW845YXZ1",13,"MIT","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"migrate oracle sp trigger to scalardb","migrate oracle","trigger","migrate","oracle","functions","opus","triggers","transaction","application","summary","migration","api","java","report","code","packages","sql","2026-11-10 10:12:30",false,"---\ndescription: Generates ScalarDB Java application code from Oracle PL\u002FSQL stored procedures, functions, packages, and triggers. Produces Java Transaction API implementations plus a summary migration report.\nmodel: opus\n---\n\n# Migrate Oracle Stored Procedures & Triggers to ScalarDB Skill\n\n## Purpose\n\nGenerate equivalent **ScalarDB Java application code** from Oracle PL\u002FSQL stored procedures, functions, packages, and triggers. Since ScalarDB does not support stored procedures or triggers, all database-side logic must be converted to application-layer Java service classes.\n\nThis skill produces **one implementation per object** using the ScalarDB Java Transaction API (Get\u002FScan\u002FInsert\u002FUpdate\u002FDelete builders).\n\n---\n\n## Skill Responsibility\n\nThis skill is responsible for:\n- Reading and parsing PL\u002FSQL definitions from extracted schema JSON\n- Classifying each object by type and feature categories used\n- Generating Java service classes with ScalarDB Java Transaction API implementations\n- Producing a summary migration report indexing all generated files\n\nThis skill is **NOT** responsible for:\n- Orchestration or command handling (handled by `\u002Foracle-to-scalardb` command)\n- Schema extraction (handled by Subagent 1)\n- Schema report generation (handled by Subagent 2)\n- General migration analysis (handled by Subagent 3)\n\n---\n\n## Input Contract\n\n| Input | Type | Required | Description |\n|-------|------|----------|-------------|\n| `raw_schema_data.json` | File | YES | Extracted Oracle schema data (specifically the `plsql` section) |\n| `oracle_schema_report.md` | File | YES | Schema report (for table\u002Fcolumn context needed for accurate Key builders) |\n| `migration-strategy-guide-sp-triggers-to-scalardb.md` | File | YES | Reference doc with 17 feature mappings and code examples |\n| `output_directory` | Directory | YES | Where to write generated files |\n\n---\n\n## Output Contract\n\n| Output | Location | Description |\n|--------|----------|-------------|\n| Java Service Classes | `\u003COUTPUT_DIR>\u002Fgenerated-java\u002F\u003CObjectName>Service.java` | One file per procedure\u002Ffunction\u002Fpackage\u002Ftrigger |\n| Summary Report | `\u003COUTPUT_DIR>\u002Fscalardb_sp_migration_report.md` | Index of all generated files with analysis |\n\n---\n\n## How to Parse the JSON\n\nRead `raw_schema_data.json` and extract these sections from `plsql`:\n\n| JSON Path | Contains |\n|-----------|----------|\n| `plsql.procedures` | Procedure metadata (name, deterministic, parallel, authid) |\n| `plsql.functions` | Function metadata (name, return_type, deterministic) |\n| `plsql.packages` | Package metadata (name, authid, spec\u002Fbody status) |\n| `plsql.package_procedures` | Procedures within packages |\n| `plsql.triggers` | Trigger metadata (name, table, timing, event, status) |\n| `plsql.arguments` | Parameters for procedures\u002Ffunctions |\n| `plsql.source` | PL\u002FSQL source code (grouped by NAME, TYPE, ordered by LINE) |\n| `plsql.trigger_source` | Trigger body source code |\n| `plsql.procedure_ddl` | Full DDL for procedures |\n| `plsql.function_ddl` | Full DDL for functions |\n| `plsql.package_ddl` | Full DDL for packages (spec + body) |\n| `plsql.trigger_ddl` | Full DDL for triggers |\n\nAlso read `oracle_schema_report.md` to extract:\n- Table names and their columns with data types\n- Primary key definitions (needed to build correct `Key.of*()` calls)\n- Foreign key relationships (needed for multi-table operations)\n\n---\n\n## Stored Procedure Type Classification\n\nClassify each stored procedure\u002Ffunction into one of these 6 categories:\n\n| # | Type | Indicators | Complexity |\n|---|------|-----------|------------|\n| 1 | Simple CRUD | Single INSERT\u002FUPDATE\u002FDELETE, no control flow | Low |\n| 2 | Business Logic | Arithmetic, conditionals, validation rules | Medium |\n| 3 | Multi-table Transaction | Writes to 2+ tables, FK relationships | Medium-High |\n| 4 | Cursor \u002F Batch Processing | CURSOR, FETCH, WHILE loops over result sets | High |\n| 5 | Aggregation | SUM, COUNT, AVG, GROUP BY | Medium |\n| 6 | Subquery-based | Nested SELECT, IN (SELECT ...), EXISTS | High |\n\n---\n\n## Trigger Type Mapping\n\nMap each Oracle trigger to its application-layer equivalent pattern:\n\n| # | Trigger Type | Application-Layer Pattern |\n|---|-------------|---------------------------|\n| 1 | BEFORE INSERT | Validation + defaults in the insert service method, before `tx.insert()` |\n| 2 | AFTER INSERT (atomic) | Additional writes (audit, counters) in the same transaction after `tx.insert()` |\n| 3 | AFTER INSERT (async) | Separate async handler (event\u002Fmessage queue) after transaction commits |\n| 4 | BEFORE UPDATE | Validate OLD→NEW transitions using `tx.get()` before `tx.update()` |\n| 5 | AFTER UPDATE | Audit trail \u002F side effects in same transaction after `tx.update()` |\n| 6 | BEFORE DELETE | Dependency checks \u002F archival using `tx.get()` before `tx.delete()` |\n| 7 | AFTER DELETE | Cascade deletes \u002F audit in same transaction after `tx.delete()` |\n| 8 | INSTEAD OF | Custom DML handler replacing view operations with multi-table logic |\n\n---\n\n## The 17 Feature Categories\n\nWhen analyzing each PL\u002FSQL object, identify which of these feature categories it uses. Each category maps to specific ScalarDB API patterns (detailed in `migration-strategy-guide-sp-triggers-to-scalardb.md`):\n\n| # | Feature | ScalarDB API Pattern |\n|---|---------|---------------------|\n| 1 | Variables (DECLARE\u002FSET\u002FINTO) | Java variables + `tx.get()` → `result.getText()` |\n| 2 | Cursors | `tx.scan()` + for loop, or `tx.getScanner()` for lazy |\n| 3 | Control flow (IF\u002FWHILE\u002FCASE) | Plain Java — no API needed |\n| 4 | Exception handling | ScalarDB exception types (`CrudConflictException`, etc.) |\n| 5 | OLD\u002FNEW row access | `tx.get()` = OLD, method params = NEW |\n| 6 | CRUD operations | Get \u002F Scan \u002F Insert \u002F Upsert \u002F Update \u002F Delete |\n| 7 | Conditional writes | `ConditionBuilder.updateIf()` \u002F `deleteIf()` |\n| 8 | Subqueries | Sequential `tx.scan()` + Java Set\u002Ffilter |\n| 9 | JOINs | Multiple `tx.get()` \u002F `tx.scan()` + Java merge |\n| 10 | Aggregations | `tx.scan()` + Java stream (sum, collect, groupingBy) |\n| 11 | SQL functions | Java equivalents (UUID, Instant, Math, String) |\n| 12 | Sequences\u002FAUTO_INCREMENT | `UUID.randomUUID()` or counter table pattern |\n| 13 | Temp tables | Java List \u002F Map \u002F Set |\n| 14 | Dynamic SQL | Builder pattern — already dynamic |\n| 15 | Output params \u002F RETURN | Java return values and result objects |\n| 16 | Transactions in SP | `tx.begin()` \u002F `tx.commit()` \u002F `tx.rollback()` |\n| 17 | Batch operations | `tx.mutate(List)` |\n\n---\n\n## Java Code Generation Rules\n\n### Target Java Version: 17\n\nAll generated Java files target **Java 17**. Use these Java 17 language features where appropriate:\n\n| Feature | When to Use |\n|---------|------------|\n| `var` | Local variable type inference for verbose generic types (e.g., `var result = tx.get(get)`) |\n| Records | Lightweight result\u002Fvalue objects (e.g., `record JobHistoryKey(int employeeId, long startDate) {}`) |\n| `instanceof` pattern matching | Replace `instanceof` + cast pairs (e.g., `if (obj instanceof String s) { ... }`) |\n| Switch expressions | Replace multi-branch `if\u002Felse` or `switch` statements returning a value |\n| Text blocks (`\"\"\"...\"\"\"`) | Multi-line SQL-like strings or error messages |\n| `List.of()` \u002F `Map.of()` | Immutable collection literals (prefer over `Arrays.asList`) |\n| `String.formatted()` | Inline string formatting (prefer over `String.format()`) |\n| Sealed interfaces | Model closed hierarchies of result types (optional, for complex SPs) |\n\n**Do not use** preview features or anything requiring Java 21+: the generated code has to compile on Java 17.\n\n### File Naming\n\n- **Procedures\u002FFunctions**: `\u003CProcedureName>Service.java` (PascalCase)\n  - Example: `CALCULATE_ORDER_TOTAL` → `CalculateOrderTotalService.java`\n- **Packages**: `\u003CPackageName>Service.java` (PascalCase, all package procedures in one file)\n  - Example: `ORDER_MGMT` → `OrderMgmtService.java`\n- **Triggers**: `\u003CTriggerName>Service.java` (PascalCase)\n  - Example: `TRG_AUDIT_LOG` → `TrgAuditLogService.java`\n\n### Class Structure\n\nEach generated `.java` file contains:\n\n```java\npackage com.example.scalardb.migration;\n\n\u002F\u002F ScalarDB Core (open source\u002Fcommunity) — default dependency.\n\u002F\u002F Only use ScalarDB Cluster if SQL interface is needed.\nimport com.scalar.db.api.*;\nimport com.scalar.db.io.Key;\nimport com.scalar.db.exception.transaction.*;\nimport java.util.*;\nimport java.util.stream.*;\n\n\u002F**\n * Migrated from Oracle PL\u002FSQL: \u003COBJECT_TYPE> \u003COBJECT_NAME>\n * Original features used: \u003Ccomma-separated feature categories>\n * SP Type: \u003Cclassification from 6 types>\n * Complexity: \u003CLow\u002FMedium\u002FMedium-High\u002FHigh>\n *\n * Java version: 17\n * Generated by ScalarDB SP & Trigger Migration Skill\n *\u002F\npublic class \u003CObjectName>Service {\n\n    private static final String NAMESPACE = \"\u003Cschema_as_is>\";\n\n    \u002F**\n     * ScalarDB Java Transaction API implementation of \u003COBJECT_NAME>\n     * Uses ScalarDB Get\u002FScan\u002FInsert\u002FUpdate\u002FDelete builders.\n     *\u002F\n    public \u003CReturnType> \u003CmethodName>(DistributedTransaction tx, \u003Cparams>)\n            throws TransactionException {\n        \u002F\u002F Transaction API implementation here — use Java 17 features (var, records, switch expressions, etc.)\n    }\n}\n```\n\n### Key Building Rules\n\nUse the schema report to determine correct key types:\n\n| Oracle Type | Key Builder |\n|-------------|------------|\n| NUMBER(p,0) p≤9 | `Key.ofInt(\"col\", value)` |\n| NUMBER(p,0) p≤18 | `Key.ofBigInt(\"col\", value)` |\n| NUMBER(p,s) s>0 | `Key.ofDouble(\"col\", value)` |\n| VARCHAR2, CHAR | `Key.ofText(\"col\", value)` |\n| NUMBER(1) boolean | `Key.ofBoolean(\"col\", value)` |\n| DATE | `Key.ofDate(\"col\", localDateValue)` — use `java.time.LocalDate` (ScalarDB 3.17+ native DATE) |\n| TIMESTAMP | `Key.ofTimestamp(\"col\", localDateTimeValue)` — use `java.time.LocalDateTime` (ScalarDB 3.17+ native TIMESTAMP) |\n\n> **Important:** ScalarDB 3.17+ supports native DATE and TIMESTAMP types. Do not map Oracle DATE to BIGINT (epoch millis) — that mapping is incorrect. Use `Key.ofDate()` with `java.time.LocalDate` for DATE columns and `Key.ofTimestamp()` with `java.time.LocalDateTime` for TIMESTAMP columns.\n\n### Error Handling Pattern\n\nEvery generated method includes proper ScalarDB exception handling:\n\n```java\ntry {\n    \u002F\u002F ... operation logic ...\n} catch (UnsatisfiedConditionException e) {\n    \u002F\u002F Conditional write failed\n} catch (CrudConflictException e) {\n    \u002F\u002F Transaction conflict — caller should retry\n    throw e;\n} catch (CommitConflictException e) {\n    \u002F\u002F Commit conflict — caller should retry\n    throw e;\n} catch (UnknownTransactionStatusException e) {\n    \u002F\u002F Unknown state — do NOT retry blindly\n    throw e;\n}\n```\n\n### Namespace Handling\n\n- Use the `ORACLE_SCHEMA` or `ORACLE_USER` value as-is for the ScalarDB namespace. Use table and column names exactly as they appear in `raw_schema_data.json` — do not convert to lowercase.\n- If `ORACLE_SCHEMA` is empty, use the `ORACLE_USER` value as-is\n- Set as a class constant: `private static final String NAMESPACE = \"\u003Cvalue>\";`\n\n---\n\n## Complexity Assessment\n\nFor each PL\u002FSQL object, calculate complexity based on:\n\n| Factor | Low | Medium | High |\n|--------|-----|--------|------|\n| Lines of code | \u003C50 | 50-200 | >200 |\n| Tables touched | 1 | 2-3 | 4+ |\n| Feature categories used | 1-3 | 4-7 | 8+ |\n| Has cursors | No | Simple | Nested\u002Fcomplex |\n| Has subqueries | No | Simple IN | Correlated |\n| Has dynamic SQL | No | — | Yes |\n| Transaction control | None\u002Fsimple | Multi-table | Savepoints |\n\n**Overall complexity:**\n- **Low**: Simple CRUD, few features, 1 table\n- **Medium**: Business logic, moderate features, 2-3 tables\n- **Medium-High**: Multi-table transactions, cursors\n- **High**: Cursor\u002Fbatch + subqueries + dynamic SQL + complex exception handling\n\n---\n\n## Report Generation\n\nAfter generating all Java files, produce `scalardb_sp_migration_report.md` using the template.\n\n> **Avoid duplicate content:** The SP migration report should only contain information unique to the SP\u002Ftrigger conversion. Do not duplicate content from the migration analysis report (`scalardb_migration_analysis.md`). Focus on: per-object conversion details, generated file index, feature usage matrix, and implementation recommendations.\n\nThe report includes:\n\n1. **Executive Summary** — counts of procedures\u002Ffunctions\u002Ftriggers, complexity breakdown\n2. **Per-Object Table** — object name, type, classification, features used, complexity, generated file\n3. **Feature Usage Matrix** — which of the 17 categories each SP uses\n4. **Unsupported Features \u002F Workarounds** — anything requiring special attention\n5. **Generated File Index** — list of all `.java` files with descriptions\n\n---\n\n## Files in This Skill\n\n```\nskills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb\u002F\n├── SKILL.md                              # This file\n├── reference\u002F\n│   └── migration-strategy-guide-sp-triggers-to-scalardb.md       # 17 feature mappings with code examples\n└── templates\u002F\n    └── scalardb_sp_migration_report.md   # Report template\n```\n\n---\n\n## Related\n\n- **Command**: `commands\u002Foracle-to-scalardb.md` (orchestration — Step 12)\n- **Schema Extraction**: `skills\u002Fmigrate-oracle\u002Fanalyze-oracle-schema\u002F` (provides raw_schema_data.json)\n- **Schema Report**: `skills\u002Fmigrate-oracle\u002Fanalyze-oracle-schema\u002F` (provides oracle_schema_report.md)\n- **Migration Analysis**: `skills\u002Fmigrate-oracle\u002Fmigrate-oracle-to-scalardb\u002F` (general migration docs)\n\n---\n\n*Skill Version: 1.1*\n*Compatible with: ScalarDB 3.17+ (ScalarDB Core \u002F open source by default; use ScalarDB Cluster only if SQL interface is needed)*\n*Target Java Version: 17*\n","# Migrate Oracle Stored Procedures & Triggers to ScalarDB Skill\n\n## Purpose\n\nGenerate equivalent **ScalarDB Java application code** from Oracle PL\u002FSQL stored procedures, functions, packages, and triggers. Since ScalarDB does not support stored procedures or triggers, all database-side logic must be converted to application-layer Java service classes.\n\nThis skill produces **one implementation per object** using the ScalarDB Java Transaction API (Get\u002FScan\u002FInsert\u002FUpdate\u002FDelete builders).\n\n---\n\n## Skill Responsibility\n\nThis skill is responsible for:\n- Reading and parsing PL\u002FSQL definitions from extracted schema JSON\n- Classifying each object by type and feature categories used\n- Generating Java service classes with ScalarDB Java Transaction API implementations\n- Producing a summary migration report indexing all generated files\n\nThis skill is **NOT** responsible for:\n- Orchestration or command handling (handled by `\u002Foracle-to-scalardb` command)\n- Schema extraction (handled by Subagent 1)\n- Schema report generation (handled by Subagent 2)\n- General migration analysis (handled by Subagent 3)\n\n---\n\n## Input Contract\n\n| Input | Type | Required | Description |\n|-------|------|----------|-------------|\n| `raw_schema_data.json` | File | YES | Extracted Oracle schema data (specifically the `plsql` section) |\n| `oracle_schema_report.md` | File | YES | Schema report (for table\u002Fcolumn context needed for accurate Key builders) |\n| `migration-strategy-guide-sp-triggers-to-scalardb.md` | File | YES | Reference doc with 17 feature mappings and code examples |\n| `output_directory` | Directory | YES | Where to write generated files |\n\n---\n\n## Output Contract\n\n| Output | Location | Description |\n|--------|----------|-------------|\n| Java Service Classes | `\u003COUTPUT_DIR>\u002Fgenerated-java\u002F\u003CObjectName>Service.java` | One file per procedure\u002Ffunction\u002Fpackage\u002Ftrigger |\n| Summary Report | `\u003COUTPUT_DIR>\u002Fscalardb_sp_migration_report.md` | Index of all generated files with analysis |\n\n---\n\n## How to Parse the JSON\n\nRead `raw_schema_data.json` and extract these sections from `plsql`:\n\n| JSON Path | Contains |\n|-----------|----------|\n| `plsql.procedures` | Procedure metadata (name, deterministic, parallel, authid) |\n| `plsql.functions` | Function metadata (name, return_type, deterministic) |\n| `plsql.packages` | Package metadata (name, authid, spec\u002Fbody status) |\n| `plsql.package_procedures` | Procedures within packages |\n| `plsql.triggers` | Trigger metadata (name, table, timing, event, status) |\n| `plsql.arguments` | Parameters for procedures\u002Ffunctions |\n| `plsql.source` | PL\u002FSQL source code (grouped by NAME, TYPE, ordered by LINE) |\n| `plsql.trigger_source` | Trigger body source code |\n| `plsql.procedure_ddl` | Full DDL for procedures |\n| `plsql.function_ddl` | Full DDL for functions |\n| `plsql.package_ddl` | Full DDL for packages (spec + body) |\n| `plsql.trigger_ddl` | Full DDL for triggers |\n\nAlso read `oracle_schema_report.md` to extract:\n- Table names and their columns with data types\n- Primary key definitions (needed to build correct `Key.of*()` calls)\n- Foreign key relationships (needed for multi-table operations)\n\n---\n\n## Stored Procedure Type Classification\n\nClassify each stored procedure\u002Ffunction into one of these 6 categories:\n\n| # | Type | Indicators | Complexity |\n|---|------|-----------|------------|\n| 1 | Simple CRUD | Single INSERT\u002FUPDATE\u002FDELETE, no control flow | Low |\n| 2 | Business Logic | Arithmetic, conditionals, validation rules | Medium |\n| 3 | Multi-table Transaction | Writes to 2+ tables, FK relationships | Medium-High |\n| 4 | Cursor \u002F Batch Processing | CURSOR, FETCH, WHILE loops over result sets | High |\n| 5 | Aggregation | SUM, COUNT, AVG, GROUP BY | Medium |\n| 6 | Subquery-based | Nested SELECT, IN (SELECT ...), EXISTS | High |\n\n---\n\n## Trigger Type Mapping\n\nMap each Oracle trigger to its application-layer equivalent pattern:\n\n| # | Trigger Type | Application-Layer Pattern |\n|---|-------------|---------------------------|\n| 1 | BEFORE INSERT | Validation + defaults in the insert service method, before `tx.insert()` |\n| 2 | AFTER INSERT (atomic) | Additional writes (audit, counters) in the same transaction after `tx.insert()` |\n| 3 | AFTER INSERT (async) | Separate async handler (event\u002Fmessage queue) after transaction commits |\n| 4 | BEFORE UPDATE | Validate OLD→NEW transitions using `tx.get()` before `tx.update()` |\n| 5 | AFTER UPDATE | Audit trail \u002F side effects in same transaction after `tx.update()` |\n| 6 | BEFORE DELETE | Dependency checks \u002F archival using `tx.get()` before `tx.delete()` |\n| 7 | AFTER DELETE | Cascade deletes \u002F audit in same transaction after `tx.delete()` |\n| 8 | INSTEAD OF | Custom DML handler replacing view operations with multi-table logic |\n\n---\n\n## The 17 Feature Categories\n\nWhen analyzing each PL\u002FSQL object, identify which of these feature categories it uses. Each category maps to specific ScalarDB API patterns (detailed in `migration-strategy-guide-sp-triggers-to-scalardb.md`):\n\n| # | Feature | ScalarDB API Pattern |\n|---|---------|---------------------|\n| 1 | Variables (DECLARE\u002FSET\u002FINTO) | Java variables + `tx.get()` → `result.getText()` |\n| 2 | Cursors | `tx.scan()` + for loop, or `tx.getScanner()` for lazy |\n| 3 | Control flow (IF\u002FWHILE\u002FCASE) | Plain Java — no API needed |\n| 4 | Exception handling | ScalarDB exception types (`CrudConflictException`, etc.) |\n| 5 | OLD\u002FNEW row access | `tx.get()` = OLD, method params = NEW |\n| 6 | CRUD operations | Get \u002F Scan \u002F Insert \u002F Upsert \u002F Update \u002F Delete |\n| 7 | Conditional writes | `ConditionBuilder.updateIf()` \u002F `deleteIf()` |\n| 8 | Subqueries | Sequential `tx.scan()` + Java Set\u002Ffilter |\n| 9 | JOINs | Multiple `tx.get()` \u002F `tx.scan()` + Java merge |\n| 10 | Aggregations | `tx.scan()` + Java stream (sum, collect, groupingBy) |\n| 11 | SQL functions | Java equivalents (UUID, Instant, Math, String) |\n| 12 | Sequences\u002FAUTO_INCREMENT | `UUID.randomUUID()` or counter table pattern |\n| 13 | Temp tables | Java List \u002F Map \u002F Set |\n| 14 | Dynamic SQL | Builder pattern — already dynamic |\n| 15 | Output params \u002F RETURN | Java return values and result objects |\n| 16 | Transactions in SP | `tx.begin()` \u002F `tx.commit()` \u002F `tx.rollback()` |\n| 17 | Batch operations | `tx.mutate(List)` |\n\n---\n\n## Java Code Generation Rules\n\n### Target Java Version: 17\n\nAll generated Java files target **Java 17**. Use these Java 17 language features where appropriate:\n\n| Feature | When to Use |\n|---------|------------|\n| `var` | Local variable type inference for verbose generic types (e.g., `var result = tx.get(get)`) |\n| Records | Lightweight result\u002Fvalue objects (e.g., `record JobHistoryKey(int employeeId, long startDate) {}`) |\n| `instanceof` pattern matching | Replace `instanceof` + cast pairs (e.g., `if (obj instanceof String s) { ... }`) |\n| Switch expressions | Replace multi-branch `if\u002Felse` or `switch` statements returning a value |\n| Text blocks (`\"\"\"...\"\"\"`) | Multi-line SQL-like strings or error messages |\n| `List.of()` \u002F `Map.of()` | Immutable collection literals (prefer over `Arrays.asList`) |\n| `String.formatted()` | Inline string formatting (prefer over `String.format()`) |\n| Sealed interfaces | Model closed hierarchies of result types (optional, for complex SPs) |\n\n**Do not use** preview features or anything requiring Java 21+: the generated code has to compile on Java 17.\n\n### File Naming\n\n- **Procedures\u002FFunctions**: `\u003CProcedureName>Service.java` (PascalCase)\n  - Example: `CALCULATE_ORDER_TOTAL` → `CalculateOrderTotalService.java`\n- **Packages**: `\u003CPackageName>Service.java` (PascalCase, all package procedures in one file)\n  - Example: `ORDER_MGMT` → `OrderMgmtService.java`\n- **Triggers**: `\u003CTriggerName>Service.java` (PascalCase)\n  - Example: `TRG_AUDIT_LOG` → `TrgAuditLogService.java`\n\n### Class Structure\n\nEach generated `.java` file contains:\n\n```java\npackage com.example.scalardb.migration;\n\n\u002F\u002F ScalarDB Core (open source\u002Fcommunity) — default dependency.\n\u002F\u002F Only use ScalarDB Cluster if SQL interface is needed.\nimport com.scalar.db.api.*;\nimport com.scalar.db.io.Key;\nimport com.scalar.db.exception.transaction.*;\nimport java.util.*;\nimport java.util.stream.*;\n\n\u002F**\n * Migrated from Oracle PL\u002FSQL: \u003COBJECT_TYPE> \u003COBJECT_NAME>\n * Original features used: \u003Ccomma-separated feature categories>\n * SP Type: \u003Cclassification from 6 types>\n * Complexity: \u003CLow\u002FMedium\u002FMedium-High\u002FHigh>\n *\n * Java version: 17\n * Generated by ScalarDB SP & Trigger Migration Skill\n *\u002F\npublic class \u003CObjectName>Service {\n\n    private static final String NAMESPACE = \"\u003Cschema_as_is>\";\n\n    \u002F**\n     * ScalarDB Java Transaction API implementation of \u003COBJECT_NAME>\n     * Uses ScalarDB Get\u002FScan\u002FInsert\u002FUpdate\u002FDelete builders.\n     *\u002F\n    public \u003CReturnType> \u003CmethodName>(DistributedTransaction tx, \u003Cparams>)\n            throws TransactionException {\n        \u002F\u002F Transaction API implementation here — use Java 17 features (var, records, switch expressions, etc.)\n    }\n}\n```\n\n### Key Building Rules\n\nUse the schema report to determine correct key types:\n\n| Oracle Type | Key Builder |\n|-------------|------------|\n| NUMBER(p,0) p≤9 | `Key.ofInt(\"col\", value)` |\n| NUMBER(p,0) p≤18 | `Key.ofBigInt(\"col\", value)` |\n| NUMBER(p,s) s>0 | `Key.ofDouble(\"col\", value)` |\n| VARCHAR2, CHAR | `Key.ofText(\"col\", value)` |\n| NUMBER(1) boolean | `Key.ofBoolean(\"col\", value)` |\n| DATE | `Key.ofDate(\"col\", localDateValue)` — use `java.time.LocalDate` (ScalarDB 3.17+ native DATE) |\n| TIMESTAMP | `Key.ofTimestamp(\"col\", localDateTimeValue)` — use `java.time.LocalDateTime` (ScalarDB 3.17+ native TIMESTAMP) |\n\n> **Important:** ScalarDB 3.17+ supports native DATE and TIMESTAMP types. Do not map Oracle DATE to BIGINT (epoch millis) — that mapping is incorrect. Use `Key.ofDate()` with `java.time.LocalDate` for DATE columns and `Key.ofTimestamp()` with `java.time.LocalDateTime` for TIMESTAMP columns.\n\n### Error Handling Pattern\n\nEvery generated method includes proper ScalarDB exception handling:\n\n```java\ntry {\n    \u002F\u002F ... operation logic ...\n} catch (UnsatisfiedConditionException e) {\n    \u002F\u002F Conditional write failed\n} catch (CrudConflictException e) {\n    \u002F\u002F Transaction conflict — caller should retry\n    throw e;\n} catch (CommitConflictException e) {\n    \u002F\u002F Commit conflict — caller should retry\n    throw e;\n} catch (UnknownTransactionStatusException e) {\n    \u002F\u002F Unknown state — do NOT retry blindly\n    throw e;\n}\n```\n\n### Namespace Handling\n\n- Use the `ORACLE_SCHEMA` or `ORACLE_USER` value as-is for the ScalarDB namespace. Use table and column names exactly as they appear in `raw_schema_data.json` — do not convert to lowercase.\n- If `ORACLE_SCHEMA` is empty, use the `ORACLE_USER` value as-is\n- Set as a class constant: `private static final String NAMESPACE = \"\u003Cvalue>\";`\n\n---\n\n## Complexity Assessment\n\nFor each PL\u002FSQL object, calculate complexity based on:\n\n| Factor | Low | Medium | High |\n|--------|-----|--------|------|\n| Lines of code | \u003C50 | 50-200 | >200 |\n| Tables touched | 1 | 2-3 | 4+ |\n| Feature categories used | 1-3 | 4-7 | 8+ |\n| Has cursors | No | Simple | Nested\u002Fcomplex |\n| Has subqueries | No | Simple IN | Correlated |\n| Has dynamic SQL | No | — | Yes |\n| Transaction control | None\u002Fsimple | Multi-table | Savepoints |\n\n**Overall complexity:**\n- **Low**: Simple CRUD, few features, 1 table\n- **Medium**: Business logic, moderate features, 2-3 tables\n- **Medium-High**: Multi-table transactions, cursors\n- **High**: Cursor\u002Fbatch + subqueries + dynamic SQL + complex exception handling\n\n---\n\n## Report Generation\n\nAfter generating all Java files, produce `scalardb_sp_migration_report.md` using the template.\n\n> **Avoid duplicate content:** The SP migration report should only contain information unique to the SP\u002Ftrigger conversion. Do not duplicate content from the migration analysis report (`scalardb_migration_analysis.md`). Focus on: per-object conversion details, generated file index, feature usage matrix, and implementation recommendations.\n\nThe report includes:\n\n1. **Executive Summary** — counts of procedures\u002Ffunctions\u002Ftriggers, complexity breakdown\n2. **Per-Object Table** — object name, type, classification, features used, complexity, generated file\n3. **Feature Usage Matrix** — which of the 17 categories each SP uses\n4. **Unsupported Features \u002F Workarounds** — anything requiring special attention\n5. **Generated File Index** — list of all `.java` files with descriptions\n\n---\n\n## Files in This Skill\n\n```\nskills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb\u002F\n├── SKILL.md                              # This file\n├── reference\u002F\n│   └── migration-strategy-guide-sp-triggers-to-scalardb.md       # 17 feature mappings with code examples\n└── templates\u002F\n    └── scalardb_sp_migration_report.md   # Report template\n```\n\n---\n\n## Related\n\n- **Command**: `commands\u002Foracle-to-scalardb.md` (orchestration — Step 12)\n- **Schema Extraction**: `skills\u002Fmigrate-oracle\u002Fanalyze-oracle-schema\u002F` (provides raw_schema_data.json)\n- **Schema Report**: `skills\u002Fmigrate-oracle\u002Fanalyze-oracle-schema\u002F` (provides oracle_schema_report.md)\n- **Migration Analysis**: `skills\u002Fmigrate-oracle\u002Fmigrate-oracle-to-scalardb\u002F` (general migration docs)\n\n---\n\n*Skill Version: 1.1*\n*Compatible with: ScalarDB 3.17+ (ScalarDB Core \u002F open source by default; use ScalarDB Cluster only if SQL interface is needed)*\n*Target Java Version: 17*\n",{"model":25,"description":7},"main","fed4c7ebb79ed82ce5c961f944a1ab0ab21bae26","skills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb",1,"https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect","https:\u002F\u002Fnexus-architect-docs-070772.gitlab.io\u002F","https:\u002F\u002Fgithub.com\u002Fwfukatsu","https:\u002F\u002Fwww.scalar-labs.com\u002F","Wataru Fukatsu | Co-Founder and CEO, Scalar, Inc.","2026-11-14 22:03:27",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add wfukatsu\u002Fnexus-architect --skill migrate-oracle-sp-trigger-to-scalardb",{"tool":58,"command":59},"bunx","bunx skills add wfukatsu\u002Fnexus-architect --skill migrate-oracle-sp-trigger-to-scalardb",{"tool":61,"command":62},"pnpm","pnpm dlx skills add wfukatsu\u002Fnexus-architect --skill migrate-oracle-sp-trigger-to-scalardb","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb\u002FSKILL.md",true,[66,72],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"reference\u002Fmigration-strategy-guide-sp-triggers-to-scalardb.md","REFERENCE","参考文档",38118,"https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb\u002Freference\u002Fmigration-strategy-guide-sp-triggers-to-scalardb.md",{"path":73,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":74,"sourceHtmlUrl":75},"templates\u002Fscalardb_sp_migration_report.md",6309,"https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fmigrate-oracle\u002Fmigrate-oracle-sp-trigger-to-scalardb\u002Ftemplates\u002Fscalardb_sp_migration_report.md",[77,85,110,131,154,174],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":84},"01M7DTDMYVAWFXAYJHXN5687Z2","doctor","Check the install and a project: plugins at the repository's version, hooks and skills in\nplace, the two knowledge bundles present and fresh, the project's registry, question store,\naudit log, learned rules and claims readable. Run it first when a command misbehaves.","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fdoctor\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":37},"01M6HRH10GPAVTZ8W90WD9HJK1","verify-sql-migration","Prove a SQL migration on data: golden checks against an authorized source database and\ndifferential tests against ScalarDB. Never touches production.","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fverify-sql-migration\u002FSKILL.md",[],[92,93,36,30,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109],"verify sql migration","verify","sonnet","tests","golden","source","Production","fetcher","data","properties","id","database","auto","true","mode","en","core","never",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":37},"01M6HRGWK643YKN0QVRQSNSDCR","verify-implementation","Check code against the design (API contract, transactions, security, requirements, the example\nchain) and report every divergence; optionally runs the eight-stage quality gate.","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fverify-implementation\u002FSKILL.md",[],[117,93,118,104,119,120,121,105,122,123,107,124,125,126,127,128,129,31,34,130],"implementation","verify implementation","quality gate","contract","design","chain","api contract","scope","backlog","repo","example","stage","check","requirements",{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":37},"01M6HRGS929NK1B5WG1ZANSXQ1","update-knowledge","Fetch or update an OKF knowledge bundle: ScalarDB\u002FScalarDL, or the vendored Kubernetes\u002FTerraform\nbundle.","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fupdate-knowledge\u002FSKILL.md",[],[138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153],"update knowledge","update","knowledge","root","plugin","bundle","Bash","terraform","status","okf","latest","kubernetes","name","haiku","Tools","fetch",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":37},"01M6HRGNMYSK70R8Y9BY41E74D","start","Interactive entry point for system architecture work: refactor a legacy application into services,\nor design a new system from requirements; picks the path from the project's state. To move a\ndatabase to ScalarDB, use migrate-database.","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fstart\u002FSKILL.md",[],[156,130,103,161,162,121,163,164,165,166,22,167,28,168,169,170,171,172,173],"Legacy","use","system","move","project","for","path","refactor","services","work","state","architecture","interactive",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":180,"publishedAt":37},"01M6HRGHZXK0NXF6W62MMNS46H","select-scalardb-edition","Choose the ScalarDB edition (Community, Enterprise Standard or Premium, plus Enterprise Options),\ndeployment mode and cluster topology through a short interview.","https:\u002F\u002Fgithub.com\u002Fwfukatsu\u002Fnexus-architect\u002Fblob\u002Fmain\u002Fskills\u002Fselect-scalardb-edition\u002FSKILL.md",[],[181,182,183,94,184,106,185,186,187,188,189,190,191],"select scalardb edition","select","topology","short","Enterprise","choose","deployment","options","cluster","interview","community"]