DATE: PIC X (10)
TIMESTAMP: PIC X (26)
TIME: PIC X (08)
The REMARKS of VARCHAR column are as follows: –
49 REMARKS – LEN PIC S9 (4) USAGE COMP.
49 REMARKS – TEXT PIC X (1920).
49 REMARKS – LEN PIC S9 (4) USAGE COMP.
49 REMARKS – TEXT PIC X (1920).
SELECT is not preferred in embedded SQL programs for three reasons. First; if the table structure is changed by the addition or deletion of a field and the program is modified then using SELECT might retrieve the columns that the user may not use. This would lead to Input-Output overhead and the chances of an index-only scan are also eliminated.
After a load, or after mass updates, inserts, deletes, or after REORG.
What is the reason that the MySQL statement “SELECT AVG (SALARY) FROM EMP” generates inaccurate output? The reason for the statement generating inaccurate outcomes is because of the fact that SALARY has not been declared to have NULL and at the same time the employees whose salary is not known are also counted.
To insert a NULL, move -1 to the null indicator. To insert a valid value, move 0 to the null indicator
-1: the field is null; 0: the field is not null; -2: the field value is truncated
Use null indicators. Syntax .. INTO HOSTVAR: NULLED
As an extra-byte prefix to the column value. Physically, the null prefix is Hex '00" if the value is present and Hex 'FF' if it is not.
There may be one of the following reasons:
probably RUN STATS is not done and the program is using a wrong index due to incorrect stats.
probably RUN STATS is done and the optimizer has chosen a wrong access path based on the latest statistics.
At run time, when the PREPARE statement is issued.
A user-defined name that is the anchor for packages. It has no physical existence. The main usage is to group packages.
The advantages of using PACKAGE are :
Avoid having to bind a large number of DBRM members into a plan
Avoid the cost of a large bind
Avoid the entire transaction being unavailable during bind and automatic rebind of a plan
Minimize fallback complexities if changes result in an error.
PLAN has the executable code for the SQL statements in the host program
DBRM: DataBase Request Module, has the SQL statements extracted from the host language program by the pre-compiler. PLAN: A result of the BIND process. It has the executable code for the SQL statements in the DBRM.
SQL command used to change the definition of DB2 objects.
Promoting a PAGE lock-size to the table or tablespace lock-size when a transaction has acquired more lock than specified in NUMLKTS. Locks should be taken on objects in single tablespace for escalation to occur.
There are three methods to determine lock-size. They are;
-Based on the lock-size given while creating the tablespace.
-Programming can direct the DB2 what lock-size to use
-If lock-size ANY is specified, DB2 usually chooses a lock-size of PAGE
During the BIND process (ISOLATION LEVEL is a parameter for the binding process ). ISOLATION (CS/PR)..
CS: Release the lock on a page after use
RR: Retains all locks acquired till the end of the transaction
There are two methods to achieve this:
Use SPUFI or QMF to EXPLAIN the dynamic SQL statement
Include EXPLAIN command in the embedded by dynamic SQL statements
Use WITH HOLD option in DECLARE CURSOR statement. But, it has no effect on pseudo-conversational CICS programs.
The ability to join rows and combaine data from two or more tables is one of the most powerful features of relational system.Three type of joins:
The b37 abend in the spufi is because of space requirements , the query has resulted in so many rows that the spufi.out file is not large enough to handle it, increase the space allocation of spufi.out file.
When you use the primary key and only the primary key in the where clause.
join is used to retrive data from different tables using a single sql statement.union is used to combine the results of two or more sql querries.
In a subquerry, if the outer querry reffers back to the outcome of innerquerry it is called corelated subquerry. That's why the outer querry is evaluated first unlike an ordinary subquerry.
BIND mainly performs two things syntax checking and authorization checking.It binds together all packages into an application plan hence the name BIND.Apart from this bind has optimiser as a subcomponent.Its function is to determine the optimum access strategy.
The answer is Locksize = ANY.Unless you are Sure what's the Purpose of tablespace ie.,Read-only or R/W.If you use lock size =any, Db2 would automatically determine what type of locks it should use.
CURRENTDATA option ensures block fetch while selecting rows from a table. In DB2V4 the default has been changed to NO. Therefore it is necessary to change all the bind cards with CURRENTDATA(YES) which is default in DB2V3 & earlier to CURRENTDATA(NO).
TYPE 1 & TYPE 2 are specified when an index is created on the table. TYPE 2 index is the option which comes with DB2V4. With TYPE 2 index data can be retreived faster as only the data pages are locked and not the index pages. Hence TYPE 2 index is recommended.
CS RR UR( added new for DB2V4 which stands for uncommited read which allows to retreive records from the space which has exclusive locks also but data integrity will be affected if this option is used )The best available option for data integrity & data concurrency is CS.
It is a data structure that must be included in any host-language program using SQL. It is used to pass feedback about the sql operations to the program. Fields are return codes, error messages, handling codes and warnings.
When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS.
When an application program executes with repeatable read protection, rows referenced by the program can’t be changed by other programs until the program reaches a commit point.
Included is the name of the database, the tablespace name, and the image copy type (full or incremental, etc..) as well as the date and time each copy was made.
The SYSIBM.SYSCOPY table contains information about image copies made of the tablespaces.
This is a seven-part value that consists of a date (yymmdd) and time (hhmmss and microseconds)
If the tablespace used is only allocated do that STOGROUP :
ALTER STOGROUP- add volume (new ) delete volume (old )
REORG TABLESPACE or RECOVER TABLESPACE
Create a new STOGROUP that points to the new volume. ALTER the tablespace and REORG or RECOVER the tablespace.
When an application program executes with repeatable read protection, rows referenced by the program can't be changed by other programs until the program reaches a commit point.
A predicate is an element of a search condition that expresses or implies a comparison operation.
This is a data item that is used in an SQL statement to receive a value or to supply a value. It must be preceded by a colon (:) to tell DB2 that the variable is not a column name.
The Data Manager is a DB2 component that manages the physical databases. It invokes other system components, as necessary, to perform detailed functions such as locking, logging, and physical I/O operations ( such as search, retrieval, update, and index maintenance).
COMMIT will allow data changes to be permanent. This then permits the data to be accessed by other units of work. When a COMMIT occurs, locks are freed so other applications can reference the just committed data.
UNION – It is the function that eliminates duplicates from the table.
UNION ALL – It is the function used to retain the duplicates in the table.
Both the functions are used to combine the results generated by multiple SELECT statements.
There is a certain point in a program at which DB2 acquires or perhaps releases the locks against tables as well as table-spaces. These include intent locks.
EXPLAIN is basically used to show the path of access by the optimizer basically for an SQL statement. Furthermore, EXPLAIN can also be brought to use in SPUFI or even in BIND step.
Even if DB2 is down at some point of time, even then it will not impact the pre-compilation process of DB2-COBOL program. The reason for the same is that the pre-compiler never refers to the catalogue tables of DB2.
There are primarily two components of DCLGEN. These are: –
A copy book of the host language, which will give alternative definitions for all the column names.
In terms of the data-types of DB2, EXEC SQL DECLARE TABLE shows an aesthetic layout of the table.
SQLERRM, SQLCODE, SQLERRD.
PACKAGES are units, which consist of executable codes that are meant for SQL statements for one respective DBRM.