|
View previous topic :: View next topic
|
| Author |
Message |
vinay_r03
New User
Joined: 20 Nov 2012 Posts: 5 Location: India
|
|
|
|
Hi all,
Below are few questions asked to me in a telephonic interview:
Q1: If there is a column in DB2 table which stores days (Viz. Monday, Tuesday etc) how do we fetch the data ordered by days? Below is the example:
PK Day
1 monday
2 wednesday
3 friday
4 saturday.
How to get the data ordered by days like given below:
Monday
Tuesday
Wednesday
Friday
Saturday
My answer:
I could not answer the question. But later i found out that using CASE statement in SELECT query we can assign values to days and give order by on that. But I am not sure yet. Could anyone help me how to solve this and give the proper syntax?
Q2: How does the records from a file be stored in MVS? Is it based on LRECL or BLK Size?
My answer:
I mentioned that records from flat file which is in fixed blocked mode will be stored in terms of Blk size as that is the physical length. LRECL is the logical record used by the developer for processing.
Q3: How do we get to know about the bytes allocated for a flat file given the number of records, record length and allocation type (Viz TRKs, CYL)
My answer:
I did not know the answer, but later found out that Total Space required for the dataset in bytes = Record Length * Maximum number of records.
Q4: Is there any DB2 command to get the access path DB2 has selected after the binding and if it is there what is that?
My answer:
I don't know the answer.
Rest were direct questions about differences between Plan and package, COBOL-DB2 execution phases (Precompile, Bind, Compile, Link, execute), SQL error codes, SQLCA, DB2 catalog tables, DISP parameters in JCL, Abends like SOC7, SB37.
I look forward to get some answers that I was wrong/not sure at it.
Thanks in advance.
With regards,
Vinay R |
|
| Back to top |
|
 |
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1055 Location: Richmond, Virginia
|
|
|
|
| Nice use of "viz." Vinay! |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
Q3: How do we get to know about the bytes allocated for a flat file given the number of records, record length and allocation type (Viz TRKs, CYL)
My answer:
I did not know the answer, but later found out that Total Space required for the dataset in bytes = Record Length * Maximum number of records.
|
the question and the terminoloy used is pretty foggy ...
as posed is pretty unclear
anyway
required in what sense ....
what You asked for
what is needed to satisfy Your request ...
what will zOS allocate
if You ask for 1(one) 80 bytes record
zOS will ( per dasd geometry ) allocate 55,840 bytes
( 2 blocks per track with optimum blksize )
| Code: |
Data Set Information
Command ===>
Data Set Name . . . . : ENRICO.MFTESTS.F1
General Data Current Allocation
Management class . . : **None** Allocated bytes . . : 55,840
Storage class . . . : **None** Allocated extents . : 1
Volume serial . . . : STOR03
Device type . . . . : 3390
Data class . . . . . : **None** Current Utilization
Organization . . . : PS Used bytes . . . . : 0
Record format . . . : FB Used extents . . . : 0
Record length . . . : 80
Block size . . . . : 27920
1st extent bytes . : 55840
Secondary bytes . . : 80
Data set name type : SMS Compressible : NO
Creation date . . . : 2012/11/28 Referenced date . . : 2012/11/28
Expiration date . . : ***None*** |
and in ISPF 3.4
| Code: |
DSLIST - Data Sets Matching ENRICO.MF* Row 1 of 1
Command ===> Scroll ===> CSR
Command - Enter "/" to select action Tracks %Used XT
-------------------------------------------------------------------------------
ENRICO.MFTESTS.F1 1 0 1
***************************** End of Data Set list ****************************
|
|
|
| Back to top |
|
 |
vinay_r03
New User
Joined: 20 Nov 2012 Posts: 5 Location: India
|
|
|
|
| Phrzby Phil wrote: |
| Nice use of "viz." Vinay! |
Thanx Phrzby Phil:) |
|
| Back to top |
|
 |
neha_cap
New User
Joined: 04 Dec 2012 Posts: 15 Location: pune
|
|
|
|
Just TO add some more questions on JCL.....which were asked in a interview:
1. If u have two files and file 1. contains records like : 100,100,100...only 3 records in it and file 2 contains records like 200, 200,200,200 only 4 records are there....Now how can we write the records in third files which contains records like 100,200,100,200,100,200 from the above files....????
2.If u have a file and one .no is key now the file have some duplicate recirds like.....100 abc
101 def
100 ghi
103 jkl
now if we want write the above record in another file which doesnt contain duplicate record and record key 100 should be selected which have ghi not the abc ...How can we do that...
Please cnswer the above two questions thru JCL do not use cobol pgms... |
|
| Back to top |
|
 |
vinay_r03
New User
Joined: 20 Nov 2012 Posts: 5 Location: India
|
|
|
|
| enrico-sorichetti wrote: |
| Quote: |
Q3: How do we get to know about the bytes allocated for a flat file given the number of records, record length and allocation type (Viz TRKs, CYL)
My answer:
I did not know the answer, but later found out that Total Space required for the dataset in bytes = Record Length * Maximum number of records.
|
the question and the terminoloy used is pretty foggy ...
as posed is pretty unclear
anyway
required in what sense ....
what You asked for
what is needed to satisfy Your request ...
what will zOS allocate
if You ask for 1(one) 80 bytes record
zOS will ( per dasd geometry ) allocate 55,840 bytes
( 2 blocks per track with optimum blksize )
| Code: |
Data Set Information
Command ===>
Data Set Name . . . . : ENRICO.MFTESTS.F1
General Data Current Allocation
Management class . . : **None** Allocated bytes . . : 55,840
Storage class . . . : **None** Allocated extents . : 1
Volume serial . . . : STOR03
Device type . . . . : 3390
Data class . . . . . : **None** Current Utilization
Organization . . . : PS Used bytes . . . . : 0
Record format . . . : FB Used extents . . . : 0
Record length . . . : 80
Block size . . . . : 27920
1st extent bytes . : 55840
Secondary bytes . . : 80
Data set name type : SMS Compressible : NO
Creation date . . . : 2012/11/28 Referenced date . . : 2012/11/28
Expiration date . . : ***None*** |
and in ISPF 3.4
| Code: |
DSLIST - Data Sets Matching ENRICO.MF* Row 1 of 1
Command ===> Scroll ===> CSR
Command - Enter "/" to select action Tracks %Used XT
-------------------------------------------------------------------------------
ENRICO.MFTESTS.F1 1 0 1
***************************** End of Data Set list ****************************
|
|
Thanks a lot for the information enrico, that helped me a lot.  |
|
| Back to top |
|
 |
vinay_r03
New User
Joined: 20 Nov 2012 Posts: 5 Location: India
|
|
|
|
[quote="neha_cap"]Just TO add some more questions on JCL.....which were asked in a interview:
2.If u have a file and one .no is key now the file have some duplicate recirds like.....100 abc
| Code: |
101 def
100 ghi
103 jkl |
now if we want write the above record in another file which doesnt contain duplicate record and record key 100 should be selected which have ghi not the abc ...How can we do that...
We can try ICETOOL for this problem: from the given scenario, assuming for every key we have to pick the last duplicate value the solution is as given below:
| Code: |
//SORT01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(INDD) TO(OUTDD) ON(1,3,ZD) LAST
DISCARD(SAVEREST)
/*
//DFSCNTL DD *
SORT FIELDS=(1,3,ZD,A)
//INDD DD DSN=ORDA.SORT.TEST.BSAM,DISP=SHR
//OUTDD DD DSN=ORDA.SORTED.TEST.BSAM,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(80,(4,2),RLSE),VOL=(,,,59),
// AVGREC=K,DCB=(RECFM=FB,LRECL=80) |
|
|
| Back to top |
|
 |
neha_cap
New User
Joined: 04 Dec 2012 Posts: 15 Location: pune
|
|
|
|
| Thank u so much Vinay!! |
|
| Back to top |
|
 |
vinay_r03
New User
Joined: 20 Nov 2012 Posts: 5 Location: India
|
|
|
|
Hi,
There is a small mistake in the piece of code I had given to pick the last duplicate. The corrected code is here.
| Code: |
//SORT01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(INDD) TO(OUTDD) ON(1,3,ZD) LAST
/*
//DFSCNTL DD *
SORT FIELDS=(1,3,ZD,A)
//INDD DD DSN=ORDA.SORT.TEST.BSAM,DISP=SHR
//OUTDD DD DSN=ORDA.SORTED.TEST.BSAM,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(80,(4,2),RLSE),VOL=(,,,59),
// AVGREC=K,DCB=(RECFM=FB,LRECL=80) |
Basically we don't need the Discard statement in the TOOLIN. |
|
| Back to top |
|
 |
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
Q1 the data ordered by days:
| Code: |
| order by DAYOFWEEK_ISO(col1) |
Q4:the access path DB2 has selected after the binding
V10 :
| Code: |
| BIND PACKAGE…EXPLAIN (ONLY) |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
did You notice that jcl/code/data snippets are displayed using the code tags for better readability. ?
and, no, it does not happen by itself, I edited Your posts to add them ( the code tags )  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|