Professional Documents
Culture Documents
* STORAGE GROUP is nothing but collection of same type of volumes (upto 133
volumes)
* DATABASE is structure to store tables, tables space and indexes
* TABLE SPACE is collecction of tables
* TABLE name can be 128 bytes long
Column name length can be upto 30 char
* VIEW - A Table which can be derived from one or more tables(max 15) based on
selection criteria
---
* DBRM - Database Request Module - where syntax free SQL are stored
* PACKAGE - component between DBRM and PLAN - containes OAP - Optimised Access
Path, generated by optimiser, a non executable component.
when any change in sub program just compile is enough, no need to bind again
* ISOLATION parameter in BIND process - how the program execution is isolated for
accessing the database which is accessed by other program concurrently
CS - Cursor Stability - DEFAULT - THE row currently being refered
RR - Repeatable read - every row referenced by current transaction
UR - Uncomited read - row is locked only when a transaction tries to update or
delete
* HOST VARIABLES - DB2 is an external system and COBOL can not access the data
directly using SQL so intermediate variables are created
* DCLGEN is a tool used to generate COBOL copybook for a table
==COBOL== ==DB2==
S9(4) COMP SMALLINT
S9(9) COMP INT
S9(18) COMP BIGINT
S9(m)V9(n) COMP-3 DECIMAL(m+n,n), NUMERIC(m+n,n)
X(n) CHAR(n)
X(n)+2 VARCHAR(n)
X(10) DATE
X(8) TIME
X(26) TIMESTAMP
* SQLCA - SQL Communication Area will include return codes, error details and codes
after DB2 query execution
* SQLCODE - INTEGER - return codes of SQL statment (0 successfull, + successfull
but warning - error)
* SQLERRD(3) - INTEGER - contains number of rows executed by particular query
* Length of SQLCA is 136
---
* DDL
-> CREATE STOGROUP <name>
VOLUMES (vol-1, vol-2, etc)
VCAT <vcat name>
* DML
Select row/rows
SELECT column_1, column_2
INTO :column-1, :column-2
FROM table_1
WHERE column_3 = :column-3
Insert row
INSERT INTO table_1
SELECT column_1
FROM table_2
WHERE condition
Insert value
INSERT INTO table_1 (column_1, column_2)
VALUES (:column-1, :column-2)
Update
UPDATE table_1
SET column_1 = :column-1
column_2 = :column-2
WHERE condition
Delete
DELETE FROM table_1
WHERE condition
* DCL
GRANT SELECT ON TABLE1 TO PUBLIC
REVOKE SELECT ON TABLE1 TO PUBLIC
----
* SQL codes -
+000 successful
+100 row not found when SELECT/UPDATE/DELETE for a condition, reached end of
ROW in CURSOR FETCH
-305 null value exception (SELECT returning null values but null indicator
not specified in INTO clause)
-313 mismatch in number of host variables and selected columns
-413 length of number is more than the max length of INT,DECIMAL column
-433 length of char is more than the max length of char, varchar column
----
----
* DEADLOCK - When multiple programs are using same resources or each other's
resource