Professional Documents
Culture Documents
System tables
GROUP BY, HAVING
LTRIM RTRIM
-904, HOW TO determine cause in spufi, DIS DATABASE (bc*) STATUS of RW,
CHKP, COPY
LOAD NOCOPYPEND (to load without causing copypend status)
EXPLAIN, sql performance
REPAIR, START, STOP,
DSNUTIL
SCALAR function examples DATE, SUBSTR, TIME, VALUE,
COLUMN functions examples MIN, MAX, AVG, COUNT, DISTINCT
COALESCE VALUE
NULL IND, sqlcode -305
-811, -805, -803
-911 deadlock causes succesfull, -913 deadlock causes unsuccesful rollback
VIEW, to restrict specific column access
VSAM & flat file, access to VSAM, dynamic and random and sequential
CS and RR
Difference between left outer join and Inner Join
Inner Join all conditions in Where must be met by row in both tables
Left Outer Join syntactically: does not use WHERE, uses ON
- even if row in Left table does not meet ON condition, left table row is
in the results table
If I were TO write all contents of a db2 table to a flat file, how would I write this
processing in my in program
If I had a nullable field, how do I code to prevent error in accessing null? Answer: by
using Null-ind, if -1, fields has nulls.
How to code without using Null-ind? Answer: Coalesce, or Value
What to code in cursor if there are columns to be updated?
If I had already written my COBOL DB2 program, what steps do I have to take to make
it executable: Precompile, (writes to DBRM), Compile, link-edit, Bind (Using
optimizer, finds which path to take)
What is a collection in DB2? Answer : group of associated packages
What is a package in DB2?
How do you dynamically change package in program? Answer
EXEC SQL SET PACKAGESET (XXXX)
What are the common SQLCODES encountered with DB2 Applications?
Consider creating additional indexes on other columns based on how often you expect the
column to be used in search criteria. Once you have identified all the desired indexes,
decide which column is apt to be used most often in search criteria. Then load the table in
that column's sequence, thus making the column's corresponding index a CLUSTERED
index.
For efficiency
Although not advisable, the easiest way of eliminating a 811 is by using the DISTINCT
clause on the SELECT statement (e.g. Exec SQL Select DISTINCT)
Check if the WHERE clause used on the SELECT comprises the unique index of the
table. If not unique, either ALTER the index of the table or change the WHERE clause on
the application such that it uses all columns of the unique index.
If multiple rows is really expected, Utilize a CURSOR
DECLARE CURSOR
OPEN
Perform a FETCH routine until SQLCODE is +100
CLOSE CURSOR
NON-SCROLLABLE - The simplest type of cursor is a non-scrollable cursor. A nonscrollable cursor always moves sequentially forward in the result table. You cannot
retrieve rows backward or move to a specific position in a result table with a nonscrollable cursor.
SCROLLABLE opposite of the definition above. This type of cursor is created by
using the SCROLL clause on the DECLARE
Error is raised by DB2 when an OPEN cursor is executed to an already open cursor
No data changes, the application does not abend
SQLCODE is raised when a CLOSE cursor is executed on a cursor that is not open
No data changes, the application does not ABEND.
What causes an SQLCODE 818? How would you handle/correct an SQLCODE 818?
The SQL precompiler places timestamp in the DBRM and in the load module of the
application program. At run-time, the two timestamps are compared with each other. If
the two timestamps do not match, the DBRM and the load module were not the result of
the same precompile. An 818 condition is then raised.
Recompile and bind the program
What are the different causes of an SQLCODE 805? How would you handle/correct
this error?
The DBRM name was not found in the member list of the plan and there is no package
list for the plan.
The package name was not found because there is no package list for the plan.
The 'location-name' in the package list was not correct when the application was bound.
The application was not connected to the proper location.
Rebind would correct the error
If due to wrong location name or connected to the wrong location, make sure that the
application connects to the right location at runtime.
What is deadlock (give a scenario)? What can you do with an SQLCODE 911?
PROGRAM A has ROW Y locked and PROGRAM B has ROW X locked. Later on,
PROGRAM A requests for ROW X and was suspended since PROGRAM B currently
locks the row. Then PROGRAM B request for ROW Y and was suspended since
PROGRAM A currently locks the row. At this point, PROGRAM A and PROGRAM B
are in DEADLOCK. DB2 would then try to rollback changes made by both programs. If
the rollback is successful, an SQLCODE 911 is raised. Otherwise, an SQLCODE 913
is raised.
Rerun the program and hope that the scenario above is not repeated.
Use the WITH UR clause on the SELECT statements on both programs for minimal row
locking.
What does an EXPLAIN do? When would you use the statement?
What is VARCHAR?
Precompile
Bind
Compile
Link Edit
Check authorizations
Check DB2 access paths
Table change
DB2 upgrade
Runstats was run causing new row count
A PLAN is a control structure that is used to execute SQL statements. The control
structures can be thought of as the bound or operational form of SQL statements taken
from a database request module (DBRM). It can also contain a list of package names. It
relates an application process to a local instance of DB2, specifying the processing
options.
The control structure that is contained inside a plan is generated when a BIND PLAN or a
BIND PACKAGE is executed. Thus, a PLAN is created after the successful execution of
a DB2 BIND subcommand.
A view provides an alternative way of looking at the data in one or more tables. A view is
a named specification of a result table. The specification is an SQL SELECT statement
that is effectively executed whenever the view is referenced in an SQL statement. At any
time, the view consists of the rows that would result if the subselect were executed. Thus,
a view can be thought of as having columns and rows just like a base table. However,
columns added to the base tables after the view is defined do not appear in the view. For
retrieval, all views can be used like base tables.
Views can be used to control access to a table and make data easier to use. Access to a
view can be granted without granting access to the table. The view can be defined to
show only portions of data in the table. A view can show summary data for a given table,
combine two or more tables in meaningful ways, or show only the selected rows that are
pertinent to the process using the view.
The state of a database in which all values of all foreign keys are valid. Maintaining
referential integrity requires the enforcement of referential constraints on all operations
that change the data in a table upon which the referential constraints are defined.
PRIMARY KEY is a unique, non-null key that is part of the definition of a table. A table
cannot be defined as a parent unless it has a unique key or primary key.
FOREIGN KEY is a column or set of columns in a dependent table of a constraint
relationship. The key must have the same number of columns, with the same descriptions,
as the primary key of the parent table. Each foreign key value must either match a parent
key value in the related parent table or be null.
What is DCLGEN?
DCLGEN is a subcomponent of DB2 that generates SQL table declarations and COBOL,
C, or PL/I data structure declarations that conform to the table. The declarations are
generated from DB2 system catalog information. DCLGEN is also a DSN subcommand.
Column functions is an operation that derives its result by using values from one or more
rows and produces a single value
Scalar functions return values to each row
tables and builds or extends any indexes defined on them. If the table space already
contains data, you can choose whether you want to add the new data to the existing data
(LOAD RESUME) or replace the existing data (LOAD REPLACE). The loaded data is
processed by any edit or validation routine associated with the table, and any field
procedure associated with any column of the table
RUNSTATS - The RUNSTATS online utility gathers summary information about the
characteristics of data in table spaces, indexes, and partitions. DB2 records this
information in the DB2 catalog and uses it to select access paths to data during the bind
process. It is available to the database administrator for evaluating database design and to
aid in determining when table spaces or indexes must be reorganized. There are two
formats for the RUNSTATS utility: RUNSTATS TABLESPACE and RUNSTATS
INDEX. RUNSTATS TABLESPACE gathers statistics on a table space and, optionally,
on indexes or columns; RUNSTATS INDEX gathers statistics only on indexes. To
update the catalog statistics, run the RUNSTATS utility after a LOAD or REBUILD
INDEX job.
REPAIR - The REPAIR online utility repairs data. The data can be your own data, or
data you would not normally access, such as space map pages and index entries. It can
be used to:
Reset a pending status on a table space or index
Verify the contents of data areas in table spaces and indexes
Replace the contents of data areas in table spaces and indexes
Add a column to an existing DB2 table using the ADD COLUMN-NAME of the ALTER
TABLE subcommand
JCL:
PARM
DISP
Symbolic Parameter
JCL Questions:
(Interview last Feb 14, 2006)
1. What generation number will y
2. ou use to create a new dataset?
3. What generation number is used to refer to a dataset created from a previous step?
4. If an abend has occurred and you do a rerun, what generation number will you use
at the restart step?
5. How do you pass a parameter from a JCL to a cobol program?
6. What will you check in your cobol program to determine if you were able to pass
a value from your JCL? (thru linkage section)
7. What is the total number of tracks used in SPACE = TRK,(5,5) ?
Cobol Questions:
(Interview last Feb 14, 2006)
1.
2.
3.
4.
Input, abend will occur, If Open Output, no abend will occur, program normally
terminates but no file created
How do you perform internal sort?
2 ways:
1.) USING, GIVING sorts are comparable to external sorts with no extra file
processing;
2.) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data
manipulation before and/or after the sort
Syntax:
SORT file-1 ON ASCENDING/DESCENDING KEY key....
USING file-2
GIVING file-3.
USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2
GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.
file-1 is the sort workfile and must be described using SD entry in FILE
SECTION
file-2 is the input file for the SORT and must be described using an FD entry in
FILE SECTION and SELECT clause in FILE CONTROL.
file-3 is the outfile from the SORT and must be described using an FD entry in
FILE SECTION and SELECT clause in FILE CONTROL.
file-1, file-2 & file-3 should not be opened explicitly.
INPUT PROCEDURE is executed before the sort and records must be
RELEASEd to the sort work file from the input procedure.
OUTPUT PROCEDURE is executed after all records have been sorted. Records
from the sort work file must be RETURNed one at a time to the output procedure.
Given a pic 9(2) field with a value of 10 and moved to a pic x(3) field. What will be
the value of the receiving field?
Answer: 10_
Numeric integer fields can be moved to alphanumeric fields but numeric fields
with a V in the pic clause cannot be moved to alphanumeric fields.
What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends?
- file matching logic (1: many file matching and many:many file matching)
What is the difference between a dynamic call and static call?
Static call statement results in the called subprogram being link-edited with the
main program into one load module. The dynamic call results in the dynamic
invocation of a separate load module.
A statically called subroutine will not be in its initial state the next time it is called
unless you explicitly use INITIAL or you do a CANCEL. A dynamically called
routine will always be in its initial state.
Logic error. e.g., a file is opened for input and an attempt is made to write to it.
How will you position an indexed file at a specific point so that the subsequent
sequential operations on the file can start from this point?
Use Start
START filename KEY IS EQ/GT/LT.. dataname
INVALID KEY ...
Subscript refers to the array occurrence while index is the displacement (in
no of bytes) from the beginning of the array.
An index can only be modified using PERFORM, SEARCH & SET. Need
to have index for a table in order to use SEARCH, SEARCH ALL Cobol
statements
What is the difference between GO BACK and STOP RUN? What happens
if you use GO BACK instead of STOP RUN in a stand-alone program?
Yes. Redefines only causes both fields to start the same location.
CICS
If I had a new transaction with maps, programs and files to access, what do I need to
define in CICS:
PPT Processing Program Table for Cobol program and Map
PCT Program Control Table for Trans-id and first program to execute
FCT For VSAM file
Where to define map, in PPT
What happens internally in CICS system once you enter trans-id on screen
Difference between Pseudo-conversational and conversational