database-application
IBM i Database Application
Analyze SQL application behavior including error logs, statement parsing, SQLCODE reference, SQL naming utilities, and system limit monitoring.
Available Tools
The ibmi CLI is the primary tool for executing database application queries. Set SKILL_DIR to this skill's installed location (the directory containing this SKILL.md file):
# SKILL_DIR = directory containing this SKILL.md
# Examples: ./skills/database-application, ~/.claude/skills/database-application
# List all database application tools
ibmi tools --tools "$SKILL_DIR/tools/" --toolset database_application_default
# Run a specific tool
ibmi tool list_sql_error_log --tools "$SKILL_DIR/tools/"
# Run with parameters
ibmi tool get_sqlcode_info --tools "$SKILL_DIR/tools/" sqlcode=-204
# Ad-hoc SQL for custom queries
ibmi sql "SELECT * FROM QSYS2.SQL_ERROR_LOG ORDER BY LOGGED_TIME DESC FETCH FIRST 10 ROWS ONLY"
The ibmi-mcp-server also provides execute_sql and describe_sql_object for MCP-connected agents.
Service Selection Guide
SQL Error Analysis
- QSYS2.SQL_ERROR_LOG -- Logged SQL errors with SQLCODE, program, statement text, timestamps
- SYSTOOLS.SQLCODE_INFO() -- Message ID, text, and help for a given SQLCODE
SQL Statement Analysis
- QSYS2.PARSE_STATEMENT() -- Extract referenced tables, views, schemas from SQL text
- QSYS2.DELIMIT_NAME() -- Properly quote/delimit SQL identifiers
System Limits
- QSYS2.SYSLIMITS -- Objects approaching system-defined size or capacity limits
Key Capabilities
SQL Error Log Analysis
- Error listing -- Recent SQL errors with SQLCODE, SQLSTATE, program, job, and statement text
- Error summary -- Aggregate error counts by SQLCODE to find the most frequent issues
- Program filtering -- Focus on errors from a specific program or library
- Occurrence tracking -- See how many times an error has occurred and when it first appeared
SQL Statement Parsing
- Object extraction -- Parse a SQL statement to find all referenced tables, views, and schemas
- Usage types -- Determine how each object is used (SELECT, INSERT, UPDATE, etc.)
- Static analysis -- Analyze SQL embedded in programs without executing it
SQLCODE Reference
- Message lookup -- Get the message ID, text, and detailed help for any SQLCODE
- Diagnosis -- Understand what a SQL error means and how to resolve it
SQL Naming Utilities
- Identifier delimiting -- Determine if a name needs quoting for safe use in dynamic SQL
- Reserved word detection -- Identify names that conflict with SQL reserved words
System Limit Monitoring
- Limit inventory -- All objects with tracked limits (file size, index size, journal, etc.)
- Near-maximum detection -- Find objects approaching their system-defined maximums
- Proactive alerts -- Identify capacity issues before they cause failures
Common Use Cases
- Error investigation -- Find SQL errors occurring in production applications
- Error trends -- Identify the most frequent SQL errors across the system
- Impact analysis -- Parse SQL to find all tables referenced by a statement
- Error diagnosis -- Look up what an SQLCODE means and how to fix it
- Dynamic SQL safety -- Determine if identifiers need delimiting
- Capacity monitoring -- Find files or indexes approaching size limits
- Proactive maintenance -- Alert before objects hit system maximums
Quick Examples
View recent SQL errors
ibmi tool list_sql_error_log --tools "$SKILL_DIR/tools/"
Errors for a specific program
ibmi tool list_sql_error_log --tools "$SKILL_DIR/tools/" program_name=MYPGM program_library=MYLIB
Look up an SQLCODE
ibmi tool get_sqlcode_info --tools "$SKILL_DIR/tools/" sqlcode=-204
Parse a SQL statement
ibmi tool parse_sql_statement --tools "$SKILL_DIR/tools/" sql_statement="SELECT * FROM MYLIB.ORDERS JOIN MYLIB.CUSTOMERS ON ORDERS.CUSTID = CUSTOMERS.ID"
Find objects near capacity limits
ibmi tool get_system_limits_near_max --tools "$SKILL_DIR/tools/" threshold_pct=75
Pre-built Tools
The tools/database-application.yaml file provides 7 ready-to-use tools:
| Tool | Description |
|---|---|
list_sql_error_log |
SQL error log entries with program and statement details |
get_sql_error_summary |
Error counts grouped by SQLCODE |
parse_sql_statement |
Extract referenced objects from SQL text |
get_sqlcode_info |
Look up message text for a SQLCODE |
delimit_name |
Check if a SQL identifier needs quoting |
get_system_limits |
System limit tracking for objects and jobs |
get_system_limits_near_max |
Objects approaching their capacity maximums |
ibmi tool <tool_name> --tools "$SKILL_DIR/tools/" # Execute
ibmi tool <tool_name> --tools "$SKILL_DIR/tools/" --dry-run # Preview SQL
ibmi tools show <tool_name> --tools "$SKILL_DIR/tools/" # View details
Reference Documentation
- Database Application Services Catalog -- Available SQL services
- Example SQL Patterns -- Working query examples
- IBM SQL_ERROR_LOG -- View documentation
- IBM SYSLIMITS -- View documentation
- IBM PARSE_STATEMENT -- Function documentation
More from ajshedivy/ibmi-agent-skills
work-management
Query, monitor, and analyze jobs on IBM i using SQL table functions via the ibmi CLI. Use when user asks about: (1) finding jobs by status, user, subsystem, or type, (2) monitoring active job performance (CPU, I/O, memory), (3) detecting long-running SQL statements, (4) analyzing lock contention, (5) checking job queues, (6) scheduled jobs, (7) job logs, (8) replacing WRKACTJOB, WRKUSRJOB, WRKSBSJOB, WRKSBMJOB commands, or (9) any IBM i work management task.
12system-health
Monitor IBM i system health including CPU, memory, disk, ASPs, system limits, and network status via SQL services. Use when user asks about: (1) CPU utilization or system status, (2) memory pool sizes or page faults, (3) disk capacity or ASP usage, (4) system limits approaching thresholds, (5) TCP/IP connections and network status, (6) system activity overview, (7) replacing WRKSYSSTS, WRKDSKSTS, WRKTCPSTS commands, or (8) any system health monitoring task.
4database-performance
Monitor IBM i database performance including index statistics, maintained temporary indexes (MTIs), database monitors, query supervisor thresholds, and materialized query tables. Use when user asks about: (1) index usage or unused indexes, (2) maintained temporary indexes and whether to create permanent indexes, (3) database monitor configuration, (4) query supervisor thresholds, (5) MQT statistics and refresh status, or (6) tables with high MTI overhead.
3template-skill
Replace with description of the skill and when Claude should use it.
3skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
3ibmi
Core skill for working with IBM i systems via the ibmi CLI and ibmi-mcp-server. Provides text-to-SQL methodology, iterative querying best practices, schema discovery, and SQL validation patterns for Db2 for i. Use as the foundation for ANY IBM i task — install this skill first, then add domain-specific skills (ibmi-database, ibmi-system) as needed.
3