0% found this document useful (0 votes)
42 views4 pages

SQL and JCL Basics for DB2 and COBOL

The document provides various SQL and JCL concepts, including how to retrieve data from a database, the execution of DB2 batch programs, and the use of SQL codes. It explains the differences between primary keys and unique indexes, how to handle nullable columns, and various JCL parameters and conditions. Additionally, it discusses methods for passing data to COBOL programs from JCL jobs and checking if a file is empty using JCL.

Uploaded by

manishkrnanand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views4 pages

SQL and JCL Basics for DB2 and COBOL

The document provides various SQL and JCL concepts, including how to retrieve data from a database, the execution of DB2 batch programs, and the use of SQL codes. It explains the differences between primary keys and unique indexes, how to handle nullable columns, and various JCL parameters and conditions. Additionally, it discusses methods for passing data to COBOL programs from JCL jobs and checking if a file is empty using JCL.

Uploaded by

manishkrnanand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

How do you retrieve the first 5 characters of FIRSTNAME column of EMP table?

o SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;

Suppose I have five SQL SELECT statements connected by UNION/UNION ALL, how many times
should I specify UNION to eliminate the duplicate rows?
o Once.

In the WHERE clause what is BETWEEN and IN?


o BETWEEN supplies a range of values while IN supplies a list of values.

How is a typical DB2 batch pgm executed?


o Use DSN utility to run a DB2 batch program from native TSO. An example is shown:

DSN SYSTEM(DSP3)
PROGRAM(EDD470BD)
RUN
PLAN(EDD470BD)
LIB ('[Link]')
END
Use IKJEFT01 utility program to run the above DSN command in a JCL.

What is a DBRM, PLAN?


o DBRM: DataBase Request Module, has the SQL statements extracted from the host language
program by the pre-compiler.
o PLAN: A result of the BIND process. It has the executable code for the SQL statements in the
DBRM.

What does it mean if the null indicator has -1, 0, -2?


o -1 : the field is null
o 0 : the field is not null
o -2 : the field value is truncated

What does the sqlcode of -818 pertain to? - GS


o This is generated when the consistency tokens in the DBRM and the load module are
different.

What is the difference between primary key & unique index?


o Primary: a relational database constraint. Primary key consists of one or more columns that
uniquely identify a row in the table. For a normalized relation, there is one designated
primary key.
o Unique index: a physical object that stores only unique values. There can be one or more
unique indexes on a table.
How do you insert a record with a nullable column?
o To insert a NULL, move -1 to the null indicator
To insert a valid value, move 0 to the null indicator

Question 27. When You Will Face Sqlcode -818?


Answer :
SQLCODE -818 is a timestamp mismatch of load module and bind timestamp
built from DBRM.
Question 122. What Is The Maximum Size Of A Numeric Field We Can
Define In Cobol?
Answer :
The maximum size of a numeric field is PIC 9(18).

Question 88. How Do You Specify A Cond Parameter For A Job Step
So That The Step Will Never Be Executed?
Answer :
COND=(0,LE) or COND=(4095,GE).

Question 60. What Are Sd37, Sb37, Se37 Abends?


Answer :
All indicate dataset out of space. SD37 - no secondary allocation was
specified. SB37 - end of vol. and no further volumes specified. SE37 - Max. of
16 extents already allocated.
1. Question 56. What Is Cond=only ?
Answer :
Means execute this step only if any of the previous steps, terminated
abnormally.
2. Question 57. What Is Cond=even ?
Answer :
Means execute this step even if any of the previous steps, terminated
abnormally.
Question 43. How To Change Default Proclib ?
Answer :
//ABCD JCLLIB ORDER=([Link],[Link])
Question 67. How Do You Restart A Proc From A Particular Step?
Answer :
In job card, specify RESTART=[Link]
where procstep = name of the jcl step that invoked the proc
and stepname = name of the proc step where you want execution to start

Question 72. What Does A Disposition Of (mod,delete,delete)


Mean ?
Answer :
The MOD will cause the dataset to be created (if it does not exist), and then
the two DELETEs will cause the dataset to be deleted whether the step
abends or not. This disposition is used to clear out a dataset at the beginning
of a job.
Question 84. What Is A Priority?
Answer :
It is a keyword parameter which specifies a job initiation priority within its job
class. When the job is initiated, the system will convert the job’s priority into
a dispatching priority so that job’s task can complete with other tasks for use
of main storage and CPU resources.
Question 90. What Is A Temporary Data Set?
Answer :
Temporary data sets are used for storage needed only for the duration of the
job. If the DISP parameter doesn’t delete the data set by the end of the job,
the system will delete it. Deleting a tape data set dismounts the tape,
whereas deleting a dataset on a direct-access volume release the storage. A
data set is marked temporary by omitting the DSN parameter or by coding
DSN=&&dsname. The system assign a unique name to the data set when
the DSN parameter is omitted, and any subsequent steps using the dataset
refer back to the DD statement.

Explain in details of available ways to requiring data passing into a


COBOL program from any JCL job?
Answer:

There have several ways to pass require data in a COBOL program from a

specific JCL job. Below three approaches can communicate it:

 Files: JCL job can able to send files directly to the COBOL program; the

program will be able to read the files and process them based on the

logic.

 PARM Parameter: If JOB accepts some PARM parameter as input, it can

easily pass on to any define COBOL program for further process as per

the logic defined by the COBOL developer.

 SYSIN DD statement: SYSIN DD statement can pick up some system

define parameter by any JCL job and send the same to a define COBOL

program for further execution.


After sending require data to the Cobol program, every JCL job is waiting to

return a response from that program and decide the JOB further process.

How can you check if a file is empty using JCL?

Common questions

Powered by AI

The RESTART parameter in JCL is used to restart a procedure from a specific step. It is specified on the job card as RESTART=procstep.stepname, where procstep is the name of the JCL step that invoked the procedure and stepname is the step within the procedure where execution should begin. Using RESTART is advantageous when a job fails, as it allows for resuming processing from a specific point without having to rerun the entire job, saving time and resources .

Temporary data sets in JCL are advantageous because they are used to store data only for the duration of a job, which means they do not persist after job completion, saving storage space and easing dataset management. They are identified by omitting the DSN parameter or using DSN=&&dsname. However, the disadvantages include that if not handled carefully, critical data might be lost as these datasets are automatically deleted at the end of the job. This requires careful planning to ensure data is correctly processed before deletion .

To retrieve the first five characters of a string in a SQL table, you can use the SUBSTR function as shown in the SQL query: SELECT SUBSTR(FIRSTNAME, 1, 5) FROM EMP;. This is useful when you need to manipulate data by trimming strings to a certain length or when you only need a subset of data, such as filtering or creating concise reports .

The BETWEEN keyword is beneficial over the IN keyword when dealing with continuous ranges of values, as it efficiently retrieves data falling between two boundaries, such as date ranges or sequences of numbers. This can simplify queries and improve readability when compared to IN, which is more suitable for discrete, unrelated values specified within a list. BETWEEN offers cleaner and potentially less error-prone syntax when the query involves concentration on a continuous interval .

Specifying just one UNION keyword is important when connecting multiple SQL SELECT statements because UNION automatically removes duplicate rows from the result set. Utilizing only one UNION keyword for the entire set of statements reduces redundancy and potential errors, ensuring that the database management system efficiently processes the operation without unnecessary repetition, which is crucial for maintaining optimal query performance .

Null indicator values in DB2 serve critical troubleshooting roles by indicating the state of a field: -1 means the field is null, 0 indicates the field is not null, and -2 signifies field value truncation. Using these indicators, developers can diagnose issues such as why a query returns unexpected null results (-1), confirm data presence (0), or resolve data integrity problems where fields contain truncated data (-2). Identifying these states helps in debugging data anomalies, improving data quality, and ensuring precise data transactions .

The DSN utility is used to execute a DB2 batch program from native TSO (Time Sharing Option). The utility enables running SQL statements embedded within the program by specifying a database system (e.g., SYSTEM(DSP3)), the program name, plan name, and the load library containing executable code. It manages the link between the logical and physical aspects of the database execution environment, ensuring that the DB2 database interactions are conducted smoothly .

Using condition codes such as COND=(0,LE) and COND=(4095,GE) in JCL to control step execution impacts job flow by specifying criteria under which steps should be skipped. COND=(0,LE) causes the step to never execute because the condition checks if the return code is less than or equal to zero, which is always true. Conversely, COND=(4095,GE) also prevents step execution as it checks if the return code is greater than or equal to 4095, which is unrealistic for typical return codes. These conditions provide a safeguard against unnecessary execution and help manage job processing logic effectively .

SQLCODE -818 indicates a timestamp mismatch between the DataBase Request Module (DBRM) and the load module. This occurs when the timestamp from the bind process does not match the timestamp in the load module. To resolve SQLCODE -818, the application needs to be rebound to ensure that the DBRM and the load module have matching consistency tokens. If left unresolved, the application may fail to execute SQL statements correctly, leading to potential data processing errors .

A primary key is a relational database constraint that consists of one or more columns uniquely identifying a row in a table, ensuring that no two rows have the same values in the primary key columns, and there is only one designated primary key per table. A unique index is a physical object that enforces uniqueness among values in one or more columns that are not necessarily primary keys, and there can be multiple unique indexes on a table .

You might also like