I have to perform 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? If I do, would I just run through database with a cursor, then process each row and take appropriate action based on the row?

Each task seems similar, but the queries are different and produce different results, so the SQL statements are very different. But they are all working with the same table.

Task 1:

  • preform 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

closed as off-topic by ratchet freak, GlenH7, Ixrec, user40980, user22815 Oct 6 '15 at 2:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – ratchet freak, GlenH7, Community, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What environment are you running in? – Paul Nathan Jul 11 '12 at 17:53
  • 1
    Why did you ask this in two places? stackoverflow.com/questions/11405227/… Please post in one or the other, not both. – zarchasmpgmr Jul 12 '12 at 21:12
  • I asked in in stack first not knowing this site. Then realized that it was more of a question for here when I read the FAQ that said this place is for "answers on conceptual questions about software development" I realized it a little late, but thought I may get a better answer here... I'll be mindful of the 2 different sites in the future before I post. – Frantumn Jul 12 '12 at 23:01
  • You can export the results of SQL to a CSV file for example: stackoverflow.com/questions/1058433/… – NoChance Sep 5 '18 at 2:40

You might be able to find some kind of query execution facility that would let you avoid writing much code for task 2 (just executing a DELETE statement), but if you need to reformat, filter or augment data, you're probably going to need to write a program. These are pretty simple tasks, though, so I would bet you can find examples without too much trouble.

  • 2
    You are correct, IBM provides Query Management Facility (QMF) as an interactive way to perform such functions or use SPUFI. See: publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/… Also, there are query tools that could connect to your mf DB2. You can invoke DB2 from JCL but you definitely want to try your queries first in a more pleasant environment. QMF has configuration limitations in some installations so have a DBA help you. If the task is not one-time off, place the SQL in JCL. do the same if the task takes long time to process. – NoChance Jul 11 '12 at 20:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.