Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Interview questions asked on DB2 and JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
vinay_r03

New User


Joined: 20 Nov 2012
Posts: 5
Location: India

PostPosted: Wed Nov 28, 2012 12:33 pm    Post subject: Interview questions asked on DB2 and JCL
Reply with quote

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. icon_smile.gif

Thanks in advance. icon_smile.gif

With regards,
Vinay R
Back to top
View user's profile Send private message

Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Wed Nov 28, 2012 6:28 pm    Post subject:
Reply with quote

Nice use of "viz." Vinay!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Nov 28, 2012 6:43 pm    Post subject: Reply to: Interview questions asked on DB2 and JCL
Reply with quote

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
View user's profile Send private message
vinay_r03

New User


Joined: 20 Nov 2012
Posts: 5
Location: India

PostPosted: Fri Dec 07, 2012 12:54 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
Nice use of "viz." Vinay!



Thanx Phrzby Phil:)
Back to top
View user's profile Send private message
neha_cap

New User


Joined: 04 Dec 2012
Posts: 15
Location: pune

PostPosted: Wed Dec 12, 2012 2:17 pm    Post subject: JCL Questions
Reply with quote

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
View user's profile Send private message
vinay_r03

New User


Joined: 20 Nov 2012
Posts: 5
Location: India

PostPosted: Wed Dec 12, 2012 2:33 pm    Post subject: Re: Reply to: Interview questions asked on DB2 and JCL
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
vinay_r03

New User


Joined: 20 Nov 2012
Posts: 5
Location: India

PostPosted: Wed Dec 12, 2012 3:46 pm    Post subject: Re: JCL Questions
Reply with quote

[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
View user's profile Send private message
neha_cap

New User


Joined: 04 Dec 2012
Posts: 15
Location: pune

PostPosted: Wed Dec 12, 2012 3:56 pm    Post subject:
Reply with quote

Thank u so much Vinay!!
Back to top
View user's profile Send private message
vinay_r03

New User


Joined: 20 Nov 2012
Posts: 5
Location: India

PostPosted: Wed Dec 12, 2012 4:01 pm    Post subject: Small correction!
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Wed Dec 12, 2012 4:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Dec 12, 2012 5:18 pm    Post subject: Reply to: Interview questions asked on DB2 and JCL
Reply with quote

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 ) icon_evil.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am
No new posts SAS Programming - Basic Questions Techelm All Other Mainframe Topics 3 Fri Mar 18, 2016 10:53 pm
No new posts Where can i find Interview questions ... Elixir Mainframe Interview Questions 4 Sat Feb 20, 2016 12:38 am
This topic is locked: you cannot edit posts or make replies. Mainframe interview on 10th Oct 2015 ... kotesh Mainframe Jobs 0 Thu Oct 08, 2015 5:21 pm
No new posts File Aid DB2 Questions niks_jude Mainframe Interview Questions 1 Mon Aug 24, 2015 5:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us