Question

I have to preform 3 tasks:
an insert, a delete, and a write

I'm not sure what the best way to do this is. My mainframe program design skills aren't too tight, so I was looking for advice.

Could I avoid doing a COBOL program for this?
The way I see it, I just need JCL that executes SQL statements. If I design my statements correctly, then they should be able to preform tasks 1 and 2 this way. But I'm thinking I may need to have a COBOL program to write to a file?

I'll overview my thought process for the 3 tasks. Each task seems similar, but they query different results, so the SQL statements are very different. But they are all working with the same table.

Task 1:
-perform SQL query
-For each row that the query picks up
- -Insert a new row based on that row

Task 2: -perform SQL query
-For each row that the query picks up
- - delete the record

Task 3:
-perform SQL query
-For each row that the query picks up
- -Write that record to a file

Was it helpful?

Solution

You cannot perform these tasks with just JCL, JCL (mostly) just causes programs to execute. To be completely accurate, JES performs these functions as it interprets JCL.

Now, you can avoid writing a program by using an existing utility or set of utilities.

SyncSort, for example, can execute a SELECT statement and write the results to a file.

DSNTEP4, for example, can execute SQL statements in batch that include DELETE, UPDATE, and INSERT statements.

So you could do this without writing a COBOL (or Assembler, or PL/I, or C/C++, or Rexx, etc.) program, just not without executing a program.

OTHER TIPS

You cannot write a program in JCL to do what you need since JCL is designed for defining and submitting jobs, not general purpose programming. You can use any supported Mainframe language to access DB2, so you can write a program in COBOL, Java, C, C++, etc. You would then need to write JCL to execute that program. The JCL would list any required information such as parameters for your program, as well as the datasets it required for input/output.

DB2 (and most other databases) have batch or command line utilities that can run arbitrary SQL statements via JCL. This is the simplest way to go, requiring nothing but JCL and some control statements. You may also have some DB2 management tools from CA, BMC or IBM that also allow arbitrary queries to be processed. The trick is expressing your requirements as a SQL query, with no additional logic (which I believe is definitely possible, given the requirements you've documented).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top