Professional Documents
Culture Documents
MF DB2
MF DB2
MF DB2
===
Pre Compile
----------
1. Expand (copied) INCLUDE members.
2. does a very basic syntax check to make sure that the column and table names are valid (that
they're spelled correctly and that the columns and the table exist). Check against DCLGEN, there is
no connection to DB2.
3. DB2 Precompiler is to split the program into two parts: a COBOL and a DB2 part.
Bind
-----
1. The first of the BIND tasks is an authorization check.
2. The second BIND task is a bit redundant. BIND, like precompile, must also check the syntax of the
SQL, but the BIND check is more sophisticated. Instead of using the top, DECLARE TABLE portion of
the DCLGEN, BIND uses the DB2 CATALOGtable information to make sure that the column names are
valid, that comparisons are numeric-to-numeric, and so on.
3. After all that input (and more) is weighed and compared, the cheapest, most cost effective access
path is chosen, and the runtime instructions for that one path are created.
BIND PARAMETERS
---------------
MEMBER - In bind package,
LIRARY - DBRM library name ,
ACTION(add/replace)- package or plan can be add or replace.
ISOLATION - Determines the duration of the page lock.
AQUIRE - Lock a table on use
RELEASE - releases when the plan terminates
VALIDATE - It will be check about authorization.
EXPLAIN - loads the access path selected by the optimizer in table
OWNER - That is the table creator name, which specifies the table needs to be accessed is dev,UAT
or Prod
SQLCODE
-------
SQLCODE -180 SQLSTATE 22007
Bad data in Date/Time/Timestamp
String representation of DATE, TIME, TIMESTAMP is invalid
SQLCODE -181 SQLSTATE 22007
Bad data in Date/Time/Timestamp
Value for DATE, TIME, TIMESTAMP is invalid
SQLCODE -305 Null indicator needed
‘-1’ : Field is having NULL value
CURSOR
-------
DECLARE C_NAME CURSOR FOR SELECT -------
DECLARE C_NAME CURSOR FOR SELECT ------- FOR UPDATE OF TABLE --> Updatable cursor
(UPDATE WHERE CURRENT OF C_NAME)
WITH HOLD-Does not close after commit/ Closes if close cursor stmt, appl'n prog terminate
(DECLARE CURSOR C_NAME CURSOR WITH HOLD FOR SELECT -------
SCROLLABLE-
ROWSET POSITIONING-
Def'n--DECLARE C_NAME CURSOR WITH ROWSET POSITIONING FOR SELECT-----
Fetch--FETCH NEXT ROESET FROM C_NAME FOR 20 ROWS INTO WS1 , WS2 ----
Need to define a variable array and need to code a fetch loop.
In open statement cursor present at first row of the result set to be processed.
SQLERRD(3)--No of rows fetched.
Alias
-----
1. Pointer to cursor.
2. substitute to 3 part name of table.
3. if table dropped, alias doesn't drop.
Synonym
-------
1. To refer table in diff name.
2. Pvt ptr.
3. If table dropped, Synonym drops
View
----
1. Alternate way of viewing data in one or more table.
2. Not physical object n doesn't store actual data.
Isolation Level
---------------
CS (Cursor Stability) Default isolation level: Hold a lock on the row or page only if the cursor is
pos'ned on that page or row. Lock is released when cursor move to new row or page, but held until
commit issued.During the lock no other appl'n can do any DB opr'n apart from SELECT.
RS (Read Stability): Lock the entire result set of the query.During the lock no other appl'n can do any
DB opr'n apart from SELECT.
UR (Uncommitted Read): Don't take any lock and ignore other lock. Allow read access to locked data.
RR (Repeatable Read): Hold lock on all rows since last commit point. Most restrictive.
COPY PENDING
------------
A state in which, an Image Copy on a table needs to be taken, In this status, the table is available
only for queries. You cannot update this table. To remove the COPY PENDING status, you take an
image copy or use REPAIR utility.
CHECK PENDING
-------------
When a table is LOADed with ENFORCE NO option, then the table is left in CHECK PENDING status. It
means that the LOAD utility did not perform constraint checking.
DELETE RULE
-----------
On delete set NULL
On delete cascade delete
On delete No action
RUNSTAT
-------
Update the statistics of the table in system cataloge tables. (no of records, no of pages etc)
REORG
-----
Organise the table on clustered index. so that system can access records easily. Needed when index
column updated.
Load Utility
------------
Term Utility(EXEC DB2TSOB)
===========
DSN SYSTEM(DT11)
-TERM UTILITY(SRFPRCE)
END
SQL
=====
1. The UNION operator selects only distinct values by default. To allow duplicate values, use the ALL
keyword with UNION.i.e. UNION ALL