SPUFI is the classic DB2I tool for editing SQL in a dataset, executing it against Db2, and browsing the results under ISPF. This tutorial walks through prerequisites, panel options, the execute-and-browse flow, verification habits, and the errors beginners hit most often.
SPUFI means SQL Processor Using File Input. You place one or more SQL statements in an input dataset. SPUFI submits them dynamically to Db2 and writes formatted output—result rows, messages, and SQLCODEs—to an output dataset. It is ideal for learning SQL, validating sample data, checking catalog rows after a bind, and performing controlled DBA checks.
SPUFI is not a replacement for application packages, batch schedules, or production change management. Use it as an interactive proof tool, then move durable SQL into the controlled path your shop requires.
| Area | What to verify |
|---|---|
| Access | TSO/ISPF access and a path to the DB2I primary option menu for your subsystem. |
| Authorization | Db2 auth ID with privileges for the SQL you intend to run. |
| Input dataset | Preallocated sequential dataset or PDS member to hold SQL text. |
| Subsystem | Correct Db2 subsystem selected in DB2I for the objects you will reference. |
| Standards | Known rules for AUTOCOMMIT, isolation, and whether change SQL is allowed in your ID. |
A simple personal input PDS such as userid.SPUFI.SQL with members for each exercise keeps work organized. Prefer a dedicated output dataset name you are willing to overwrite on every run.
| Option | What it controls |
|---|---|
| CHANGE DEFAULTS | Open the SPUFI defaults panel for isolation, formatting, and control values |
| EDIT INPUT | YES opens ISPF edit on the input SQL; NO skips editing |
| EXECUTE | YES sends the input SQL to Db2 for processing |
| AUTOCOMMIT | YES commits after a successful run; NO prompts for commit/rollback |
| BROWSE OUTPUT | YES opens an ISPF browse of the output dataset after execution |
For a first successful query, a common choice is EDIT INPUT YES, EXECUTE YES, AUTOCOMMIT YES, and BROWSE OUTPUT YES. Switch AUTOCOMMIT to NO when you want an explicit decision before making data changes permanent.
Create a sequential dataset or PDS member before opening SPUFI. The member can be empty; you will edit it in the next step.
From the DB2I Primary Option Menu, select SPUFI. On the SPUFI panel, fill in the input dataset name and an output dataset name such as RESULT or userid.SPUFI.OUT.
12345678SPUFI panel (conceptual) 1 INPUT DATA SET ===> 'STEVE.SPUFI.SQL(EMPSEL)' 4 OUTPUT DATA SET ===> 'STEVE.SPUFI.OUT' 5 CHANGE DEFAULTS ===> N 6 EDIT INPUT ===> Y 7 EXECUTE ===> Y 8 AUTOCOMMIT ===> Y 9 BROWSE OUTPUT ===> Y
When EDIT INPUT is YES, ISPF edit opens. Enter one or more SQL statements. End statements according to your SPUFI defaults (often a semicolon). Keep teaching examples small and intentional.
1234SELECT EMP_ID, EMP_NAME, DEPT_CODE, SALARY FROM TRAINING.EMPLOYEE WHERE DEPT_CODE = 'A10' ORDER BY EMP_ID;
Press Enter to process. With EXECUTE YES, SPUFI sends the input to Db2. With BROWSE OUTPUT YES, you land in an ISPF browse of the output dataset. Read every SQLCODE, not only the result table. The summary at the end shows whether the run committed or rolled back.
Leave the SQL in the input member. Next time, set EDIT INPUT to NO if no changes are needed, keep EXECUTE YES, and press Enter. This makes SPUFI a fast regression tool for the same verification query after an application run or bind.
1234-- Follow-up verification after a sample insert through SPUFI SELECT EMP_ID, EMP_NAME, DEPT_CODE FROM TRAINING.EMPLOYEE WHERE EMP_NAME = 'LINDA CHEN';
| Symptom | Likely cause | Corrective action |
|---|---|---|
| Input dataset not found | Dataset or member was never allocated, or the name is misspelled | Allocate the input dataset/member and re-enter the exact name on the SPUFI panel. |
| SQLCODE -204 / object not found | Wrong schema, misspelled name, or wrong subsystem | Qualify objects, confirm CURRENT SQLID/schema expectations, and verify DB2I subsystem. |
| SQLCODE -551 / authorization failure | Auth ID lacks SELECT/INSERT/UPDATE/DELETE or other required privilege | Request the minimum grant or switch to an authorized role per shop process. |
| Unexpected rollback of changes | AUTOCOMMIT NO and rollback chosen, or a later statement failed in the unit of work | Read the output summary for commit/rollback, fix failing SQL, and rerun deliberately. |
| Output hard to read / truncated | Defaults for line length, max numeric digits, or result formatting | Use CHANGE DEFAULTS to adjust formatting and rerun the same input member. |
Another frequent beginner mistake is running change SQL against a shared training table without a cleanup plan. Prefer personal schemas or clearly tagged sample keys, and leave AUTOCOMMIT NO until you have inspected the preview queries.
SPUFI is like a homework notebook for Db2. You write your questions on a page (the input dataset), hand the notebook to Db2, and Db2 writes the answers on another page (the output dataset). AUTOCOMMIT is whether you permanently ink the changes or keep an eraser handy. BROWSE OUTPUT is simply opening the answer page to read it.
1. Where do you normally start SPUFI?
2. Which dataset must already exist before you use SPUFI?
3. What does AUTOCOMMIT YES do after a successful SPUFI run?
4. If the input member already contains the SQL you want, which option skips the editor?
5. What should you check first when SPUFI output shows a negative SQLCODE?