
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6705 Articles for Database

3K+ Views
The SHARED, UPDATE and EXCLUSIVE are the types of locks which are used in concurrent application processing. This means that these locks are used when the two or more applications try to access the same row or page. Below is the description for each type of lock.SHARED LOCKIf any application acquires SHARED LOCK on a page, then it can read that page but cannot update it. Other concurrent applications can acquire the SHARED or UPDATE lock on the same page.UPDATE LOCKIf any application acquires UPDATE LOCK on a page, then it can read that page but cannot update it. In ... Read More

836 Views
The NON-REPEATABLE READ conditions occur when the COBOL-DB2 program executes the same query multiple times, but the result of the query is different each time. This generally happens when two COBOL-DB2 programs access the same row of the DB2 table.The first program reads the row, then the second program reads the same row, updates it and commits the changes. The first program again reads the same row but now the data does not match with the previous fetch.The PHANTOM condition occurs when the number of rows in the query result does not match when the query is executed multiple times.For ... Read More

961 Views
The LOST UPDATE and DIRTY read issues are related to concurrency. The concurrency is defined as the ability of two or more applications to access the same table data.The LOST UPDATE impacts the processing of COBOL-DB2 programs in the following way.Suppose there are 2 application programs — PROG A and PROG B which are trying to access the same row of ORDERS DB2 table. PROG A and PROG B read a row from the ORDERS table with ORDER_ID = ‘Z87661’ at the same time. PROG A updates some data in this row and commits the changes. PROG B now updates ... Read More

13K+ Views
Problem: A COBOL-DB2 program takes the data from an input file having 1000 records and inserts the data in a DB2 table. The program failed after 432nd record. How will you implement restart logic?SolutionThe restart logic can be implemented in a COBOL-DB2 program by fixing a commit frequency. If we choose a commit frequency of 100, then the following steps need to be performed:Declare a variable for a counter, say WS-COUNT.Place a loop in which we will read the record from the file and insert it in a database. Increment the counter WS-COUNT by one each time a record is ... Read More

293 Views
Problem: Explain the difference between Multi-index access and Index-only access paths used by DB2 Optimizer. Give an example for both.SolutionThe Index-only access and Multi-index access are the types of access path which the DB2 optimizer chooses in order to fetch the query results. The Index-only access paths are used when all the columns given in the SELECT query are present in the index. In this case, the optimizer does not have to go to the data page to fetch the result, all the data is available in the index page.For example, the ORDERS table has a primary key as ORDER_ID ... Read More

3K+ Views
The UNION in DB2 is used to merge two or more SELECT statements. The SELECT statements can be on a single table or on multiple tables. Each SELECT statement is processed individually and their results are combined to give us the final result rows.The UNION statement will eliminate the duplicate rows appearing as a result of SELECT statements. If we want to retain the duplicate rows, then we can use the UNION ALL statement.For example, if we want to extract all ORDER_ID with ORDER_TOTAL greater than 1000 in ORDERS and ORDERS_HIST table, we can use the below query with a ... Read More

224 Views
The EXECUTE IMMEDIATE and EXECUTE with PREPARE could not be used for SELECT query. For the SELECT query, we have a fixed list SELECT in which the column to be fetched remains fixed and it cannot be changed.For example, if we want to select the orders placed on 14-08-2020. Then we can use dynamic SQL as given below:ExampleMOVE ‘SELECT ORDER_ID FROM ORDERS WHERE ORDER_DATE=?’ TO WS-SQL-QUERY EXEC SQL DECLARE ORDER-CUR CURSOR FOR SELQUERY END-EXEC EXEC SQL PREPARE SELQUERY FROM :WS-SQL-QUERY END-EXEC MOVE ‘14-08-2020’ TO WS-ORDER-DATE EXEC SQL OPEN ORDER-CUR USING :WS-ORDER-DATE END-EXEC PERFORM UNTIL SQLCODE = +100 ... Read More

874 Views
The EXECUTE IMMEDIATE and EXECUTE PREPARE are the forms of dynamic SQL. In case of EXECUTE immediate, we can give the SQL statement in the host variable and pass this host variable in EXECUTE IMMEDIATE.Following example demonstrates these forms.Example01 WS-SQL-DECLARE 05 WS-SQL-LEN PIC S9(04) COMP. 05 WS-SQL-QUERY PIC X(70). MOVE +80 TO WS-SQL-LEN MOVE “UPDATE ORDERS SET ORDER_PAID = ‘YES’ WHERE ORDER_DATE = ‘14-08-2020’” TO WS-SQL-QUERY EXEC SQL EXECUTE IMMEDIATE :WS-SQL-DECLARE END-EXECIn case of EXECUTE PREPARE, the SQL statement is first prepared and then executed. We can use this form of dynamic SQL ... Read More

1K+ Views
A static SQL is hardcoded in COBOL-DB2 program and the SQL query cannot change during the program execution. We can only change the value of the host variables. In the case of DYNAMIC SQL, we can change the columns, tables and predicates in the COBOL-DB2 program in run time.For example, based on the current date, we can update ORDERS or ORDERS_HIST table. This query can be built using DYNAMIC SQL which includes ORDERS table or ORDER_HIST table.The main advantage of DYNAMIC SQL is its flexibility. We can add columns or change tables/predicates as per our business logic. On the other ... Read More

166 Views
The QBLOCK_TYPE column of the PLAN_TABLE mainly gives the information about the type of query. It can have the value as CORSUB which indicates that the query is Correlated subquery and NCOSUB indicates that the query is Non-correlated subquery.The JOIN_TYPE column indicates the type of join used in the query. This column can take the value as per the below table.Column valueInterpretationBLANKINNER JOIN/NO JOINFFULL OUTER JOINLLEFT OUTER JOINRRIGHT OUTER JOIN