harwell:runs:write, which includes the harwell:runs:read tools used here.
1. Seed the tables
DB/seed.sql holds the DDL and rows a fresh volume starts with.
DB/seed.sql:
2. Run SQL from a program
Progs/RAISE.cbl:
Procs/RAISEJOB.jcl:
run.json:
3. Keep the volume
Each call gets a fresh volume, discarded when the call ends, unless you keep it. Setreturn_work:
BAL=000501000. The result names the kept volume:
4. Query the tables
sql runs one SELECT, WITH or VALUES statement in Db2’s dialect, read-only. A statement that fails returns Db2’s SQLCODE and SQLSTATE: -204 for an unknown table, -206 for an unknown column, -104 for a syntax error.
5. List the data sets
* matches within one qualifier, ** across qualifiers and % one character.
6. Read records
copybook is the copybook’s source text. Pass copybooks ({MEMBER: source}) for each COPY it contains. A KSDS or RRDS a program wrote is refused: REPRO it to a sequential data set in a job, then read that.
7. Carry on from the volume
Pass thework_id to the next call. It starts from the state the last run left:
502000. To carry state without passing ids, use a system.
SQLCODEs in a result
Every SQL statement that ends with a negative SQLCODE is a warning in the result’sdiagnostics, at the program’s line, whether or not the program checks SQLCODE:
SQL in CALLed programs
A subprogram withEXEC SQL, CALLed from a batch or online program, runs its SQL on the caller’s unit of work, as on z/OS.