- Home
- Skills
- Data & Databases
- as400 sql data query
as400 sql data query
Run read-only SQL queries against IBM i (AS/400) DB2 databases to analyze legacy ERP data.
$2
Works with the AI Agents you already use
as400 sql data query
Example session with this skill installed
List the top 5 customers from library PRODLIB file CUSTMAST who were added in 2023. The date field is CDATE in YYYYMMDD numeric format.
- Read your context and instructions
- Compiled the as400 sql data
I have queried the PRODLIB.CUSTMAST file, filtering for records where CDATE falls within the year 2023. I used FETCH FIRST 5 ROWS ONLY to retrieve the top records and converted the numeric dates for readability.
Top 5 Customers Added in 2023
| Customer ID | Name | Add Date | Status |
|---|---|---|---|
| 10442 | ACME INDUSTRIAL | 2023-01-15 | A |
| 10589 | GLOBAL LOGISTICS | 2023-03-22 | A |
| 10612 | BAKER RETAIL | 2023-06-05 | I |
| 10774 | ZETA SYSTEMS | 2023-08-14 | A |
| 10821 | NORTHERN TECH | 2023-11-30 | A |
Query Executed:
SELECT CUSTID, CNAME,
DATE(TIMESTAMP_FORMAT(CHAR(CDATE), 'YYYYMMDD')) AS ADD_DATE,
CSTAT
FROM PRODLIB.CUSTMAST
WHERE CDATE BETWEEN 20230101 AND 20231231
ORDER BY CDATE DESC
FETCH FIRST 5 ROWS ONLY
Assumptions & Notes:
- Date Conversion:
CDATEwas treated as a numeric YYYYMMDD field based on your description. - Library: Used
PRODLIBas the qualifier for theCUSTMASTphysical file. - Status Codes:
CSTATcolumn was included to show record activity, though not filtered.
Next steps
- Verify if 'I' status (Inactive) should be excluded from future customer lists.
- Check
PRODLIB.CUSTADDRif you need to join and display physical addresses for these IDs.
Connects securely to your tools. The creator never sees your data.
About this skill
Legacy ERP systems running on IBM i often trap critical business data behind cryptic physical file names and non-standard SQL dialects. This skill enables precise data extraction and analysis from DB2 for i databases using read-only SELECT and WITH statements.
What it does
- Execute queries runs SELECT and WITH statements against physical and logical files (PF/LF).
- Inspect data performs peeks with
FETCH FIRSTto verify padding, case, and legacy encoding. - Join legacy tables links master and detail files even when formal foreign keys are missing.
- Discover codes runs
SELECT DISTINCTto interpret flags and coded fields without guessing. - Handle legacy types converts numeric dates (CYYMMDD) and packed decimals into usable formats.
How it works
- Identify targets by using catalog tools to find the correct library, file, and field names.
- Profile data by checking for blank-padding, null values, and specific legacy date formats.
- Draft query using DB2 for i syntax like
FETCH FIRST n ROWS ONLYand qualifiedLIB.TABLEnames. - Verify and present by running the query and returning a formatted result with interpreted assumptions.
Frameworks & tools
Specifically designed for IBM i (AS/400, iSeries) DB2 databases. Works with legacy PF/LF models and modern DDL-defined tables using the as400_sql_query tool.
Why this beats prompting it yourself
Writing SQL for IBM i requires navigating specific constraints like blank-padded CHAR columns, numeric date conversions, and mandatory library qualification. This skill automates the profiling steps needed to ensure join cardinality is correct and prevents common syntax errors like using LIMIT instead of FETCH FIRST.
Use cases
- Customer reporting listing specific cohorts by joining master files with address files.
- Audit checks identifying orphaned records or invalid flags in legacy ERP modules.
- Data profiling determining the range and distribution of values in cryptic columns.
- Financial snapshots aggregating totals from transactional files with numeric date filters.
Known limitations
Does not support DML (INSERT/UPDATE/DELETE) or DDL (CREATE/DROP) operations. Access to IFS or spool data via SQL table functions is blocked. Queries are limited to 60 seconds and a maximum row cap.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Read-only SELECT/WITH only. No DML/DDL. Requires qualified LIB.TABLE names if ALLOWED_LIBS is active. 60s timeout. No IFS/spool table functions.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 7 days ago
- Software
- As400 Basics MCP
Permissions
No special permissions declared or detected