Assume there is a table having customer data which includes CUST_NUMBER,NUMBER_OF_BULBS(Millions of records).
Now to calculate the fee for each customer based on number of bulbs,I have two options in my mind
1. To take the unload of data to a file then by using COBOL file handing methods, read the file and Calculate the fee for each customer
2. In COBOL by using SQL query calculate the fee for each customer
Out of two given options which one is better and why?
File handling vs SQL query?
-
- Posts: 3
- Joined: Mon Oct 31, 2016 12:07 pm
- Skillset: COBOL, JCL
- Referer: Google
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: File handling vs SQL query?
If you are using files you are not on a mainframe so the question is irrelevant as mainframes use data sets not files.
If this is a course question then answer using the information that you have learned in your course. If you are simply curious then ask your teacher.
If this is a course question then answer using the information that you have learned in your course. If you are simply curious then ask your teacher.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: File handling vs SQL query?
If you are using files you are not on a mainframe
does that imply the the cobol standards committee f***ed up things

when used the term
Code: Select all
FILE SECTION
instead of
Code: Select all
DATASET SECTION
so that' s the reason for the opinion that
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
- Akatsukami
- Global moderator
- Posts: 1058
- Joined: Sat Oct 16, 2010 2:31 am
- Skillset: Rexx, JCL, DB2/SQL, TSO/ISPF, PL/I
- Referer: ibmmainframes
- Location: Bloomington, IL
- Contact:
Re: File handling vs SQL query?
I respectfully disagree.
COBOL isn't a z/OS (or OS/360) proprietary language, it's a COmmon Business-Oriented Language. We'd justly mock ANSI if they'd defined it using jargon specific to Burroughs mainframes, PDP-11s, or Wintel boxes; there is equally no reason why that definition should be couched in IBM terminology.
Moreover, COBOL internal files map to JCL external files, which in turn map to z/OS data sets. The whole purpose of JCL is to avoid the tight coupling of a program to its environment that is seen on toy computers.
COBOL isn't a z/OS (or OS/360) proprietary language, it's a COmmon Business-Oriented Language. We'd justly mock ANSI if they'd defined it using jargon specific to Burroughs mainframes, PDP-11s, or Wintel boxes; there is equally no reason why that definition should be couched in IBM terminology.
Moreover, COBOL internal files map to JCL external files, which in turn map to z/OS data sets. The whole purpose of JCL is to avoid the tight coupling of a program to its environment that is seen on toy computers.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: File handling vs SQL query?
I had forgot to put the smiley,
and You took the thing too seriously John
edited my post to put a smile where it belongs.
and You took the thing too seriously John

edited my post to put a smile where it belongs.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
- Akatsukami
- Global moderator
- Posts: 1058
- Joined: Sat Oct 16, 2010 2:31 am
- Skillset: Rexx, JCL, DB2/SQL, TSO/ISPF, PL/I
- Referer: ibmmainframes
- Location: Bloomington, IL
- Contact:
Re: File handling vs SQL query?
Poe's Law strikes again 

"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: File handling vs SQL query?
I've been wanting to say this for ages:
it is
not

it is
Code: Select all
DSN= (or DSNAME=)
not
Code: Select all
FN= (or FNAME=)


The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
-
- Global moderator
- Posts: 2105
- Joined: Thu Jun 03, 2010 6:21 pm
- Skillset: Assembler, JCL, utilities
- Referer: zos.efglobe.com
Re: File handling vs SQL query?
Akatsukami wrote:... The whole purpose of JCL is to avoid the tight coupling of a program to its environment that is seen on toy computers.
Absolutely. Not only that; to avoid programs from defining their environment. In other words, to use OS/360 as an example, discourage functional capabilities like the things IEHMOVE used to do.
Of course it can't be done, but wouldn't it be nice to go back 50 years in time and interview the senior designers about their motivation? I suspect most would argue they were trying to conserve storage, both core storage in the user programs and external storage both for the user programs and system data set storage required to implement the capability. Another issue is they were implementing a batch system rather than an interactive system.
I'd bet the designers of main device scheduling in ASP and JES3 are still grumbling about the loss of control caused by dynamic allocation!
Of course we're now in the realm of JCL rather than SQL and DB2!
-
- Global moderator
- Posts: 2105
- Joined: Thu Jun 03, 2010 6:21 pm
- Skillset: Assembler, JCL, utilities
- Referer: zos.efglobe.com
Re: File handling vs SQL query?
To return to the topic; the whole point of SQL/DB2 is to not spin through all the data to pick out a few lines of the data.
-
- Posts: 47
- Joined: Sat Aug 30, 2014 3:52 pm
- Skillset: JCL, COBOL, DB2, CICS, VSAM, MQ
- Referer: Internet
Re: File handling vs SQL query?
@Harhsaa_KK
That kind of tells that there must be a column that stores the usage of electricity, if yes, then please mention it.
Now, coming to your query on which method to use:
It depends on various factors:
-> which type of file you use in you COBOL code to bill the customers. Do the concerned fields from a part of some key if you are to use VSAM files ?
-> In case you are going to use DB2 (and not the unloaded file) - then is there an INDEX on the 2-3 columns in the picture? if yes, then It will speed up the processing. If you let DB2 do the work, then make sure you select only the required columns in your SQL to do the calculations as it will keep I/O costs to a minimum. Use a cursor to make sure you process each customer's record.
Now to calculate the fee for each customer based on number of bulbs
That kind of tells that there must be a column that stores the usage of electricity, if yes, then please mention it.
Now, coming to your query on which method to use:
It depends on various factors:
-> which type of file you use in you COBOL code to bill the customers. Do the concerned fields from a part of some key if you are to use VSAM files ?
-> In case you are going to use DB2 (and not the unloaded file) - then is there an INDEX on the 2-3 columns in the picture? if yes, then It will speed up the processing. If you let DB2 do the work, then make sure you select only the required columns in your SQL to do the calculations as it will keep I/O costs to a minimum. Use a cursor to make sure you process each customer's record.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
File Handling 3 input files and 1 output file by using EZT
by pavan426 » Thu Sep 09, 2021 12:17 am » in CA-Easytrieve - 0
- 4421
-
by pavan426
View the latest post
Thu Sep 09, 2021 12:17 am
-
-
-
regarding COBOL WRITE verb (VB File Handling)
by anonguy456 » Mon Jun 28, 2021 5:57 pm » in IBM Cobol - 6
- 3857
-
by Robert Sample
View the latest post
Tue Jun 29, 2021 11:33 pm
-
-
-
Array processing and Table handling with packed decimal
by rogerstrycova » Tue Oct 26, 2021 3:55 pm » in IBM Cobol - 2
- 1706
-
by Robert Sample
View the latest post
Wed Oct 27, 2021 1:12 am
-
-
- 0
- 2570
-
by JIMDOOEY
View the latest post
Tue Mar 01, 2022 8:48 am
-
- 7
- 11716
-
by AusZosGuy
View the latest post
Fri Sep 10, 2021 6:40 pm