File handling vs SQL query?



IBM's flagship relational database management system

File handling vs SQL query?

Postby Harhsaa_KK » Mon Oct 31, 2016 3:55 pm

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?
Harhsaa_KK
 
Posts: 3
Joined: Mon Oct 31, 2016 12:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File handling vs SQL query?

 

Re: File handling vs SQL query?

Postby NicC » Mon Oct 31, 2016 4:06 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2531
Joined: Sun Jul 04, 2010 12:13 am
Location: Down on the pig farm
Has thanked: 4 times
Been thanked: 88 times

Re: File handling vs SQL query?

Postby enrico-sorichetti » Mon Oct 31, 2016 8:05 pm

If you are using files you are not on a mainframe


does that imply the the cobol standards committee f***ed up things :D

when used the term
FILE SECTION

instead of
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-sorichetti
Global moderator
 
Posts: 2519
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 120 times

Re: File handling vs SQL query?

Postby Akatsukami » Mon Oct 31, 2016 8:48 pm

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.
"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
User avatar
Akatsukami
Global moderator
 
Posts: 1005
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 48 times

Re: File handling vs SQL query?

Postby enrico-sorichetti » Mon Oct 31, 2016 9:03 pm

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.
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-sorichetti
Global moderator
 
Posts: 2519
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 120 times

Re: File handling vs SQL query?

Postby Akatsukami » Mon Oct 31, 2016 9:21 pm

Poe's Law strikes again :oops:
"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
User avatar
Akatsukami
Global moderator
 
Posts: 1005
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 48 times

Re: File handling vs SQL query?

Postby NicC » Tue Nov 01, 2016 3:15 pm

I've been wanting to say this for ages:
it is
DSN= (or DSNAME=)

not
FN= (or FNAME=)

:) :)
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2531
Joined: Sun Jul 04, 2010 12:13 am
Location: Down on the pig farm
Has thanked: 4 times
Been thanked: 88 times

Re: File handling vs SQL query?

Postby steve-myers » Tue Nov 01, 2016 5:13 pm

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!
steve-myers
Global moderator
 
Posts: 1792
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 173 times

Re: File handling vs SQL query?

Postby steve-myers » Tue Nov 01, 2016 5:20 pm

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.
steve-myers
Global moderator
 
Posts: 1792
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 173 times

Re: File handling vs SQL query?

Postby pranav283 » Wed Nov 02, 2016 11:58 am

@Harhsaa_KK

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.
pranav283
 
Posts: 34
Joined: Sat Aug 30, 2014 3:52 pm
Has thanked: 1 time
Been thanked: 0 time

Next

Return to DB2

 


  • Related topics
    Replies
    Views
    Last post