Mandalika has Published 470 Articles

Write the syntax to declare a scrollable cursor on the ORDERS DB2 table.

Mandalika

Mandalika

Updated on 15-Sep-2020 11:08:13

630 Views

A SCROLLABLE CURSOR can move in both forward and backward direction. In other words, it can fetch next as well as previous rows. A SCROLLABLE CURSOR is declared using the “SCROLL” clause in the DECLARE CURSOR.For example, if we want to declare a SCROLLABLE CURSOR on the ORDERS table then ... Read More

What is the purpose and usage of SCROLLABLE CURSOR in COBOLDB2 program?

Mandalika

Mandalika

Updated on 15-Sep-2020 11:06:45

625 Views

A cursor can move only in forward direction, which means that it can extract the next row after every fetch. It is not possible to extract the previous row using a cursor.For example, if our resultant cursor contains following rows−ORDER_IDORDER_DATEA223672020-07-28A667562020-07-28A778902020-07-29A968322020-07-29If our cursor is currently pointing to 3rd row i.e. order ... Read More

What is the purpose and usage of ATOMIC and NON-ATOMIC clause in multi row insert?

Mandalika

Mandalika

Updated on 15-Sep-2020 11:03:38

877 Views

The ATOMIC and NON ATOMIC clauses are used with the multi-row insert. ATOMIC is always processed by default if any of the options is not given. The ATOMIC clause states that if there is a failure while inserting any one row during multi-row insertion then the entire query will be ... Read More

How to insert multiple rows in a table using a single INSERT command in program?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:58:18

756 Views

If we want to insert a multiple rows in a DB2 table using a single INSERT command then we have to define the host variable array and move the row data we want to insert in that array. We need to define another variable in the working storage section with ... Read More

What is the usage of host variables in case of multi row fetch?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:55:55

254 Views

The host variable needs to be declared as an array for the multi-row fetch. Also, we need to define another variable in the working storage section with the configuration S9(4) COMP, which will store the value of the number of rows to be fetched in a single fetch call.We can ... Read More

How will you extract multiple rows from a DB2 table in a single FETCH call?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:51:31

1K+ Views

We can extract multiple rows from a DB2 table in a single FETCH call using a concept of multi row fetch.In a multi row fetch, we have to declare the cursor with the clause “WITH ROWSET POSITIONING”. The host variable in this case should be declared as an array.Therefore, in ... Read More

How to fetch data from an unopened cursor or opening an already opened cursor?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:49:03

146 Views

When we try to fetch the data from the CURSOR which is not open the query will fail. In this case the SQLCODE field of SQLCA will be populated with the DB2 error code - 501. As per the IBM documentation -501 error code states that−“THE CURSOR IDENTIFIED IN A ... Read More

Is it possible to update a CURSOR in which we have used JOIN on 2 tables ORDERS and TRANSACTIONS? Why or Why not? How can we proceed to UPDATE any of these tables?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:47:15

83 Views

When we use JOIN on one (self join) or more table inside a cursor declaration then a read-only cursor will be created. We cannot update the read-only cursor.If we want to update any of the tables used in the JOIN then we have to declare a separate cursor for all ... Read More

How will you keep the CURSOR open after firing COMMIT in a COBOL-DB2 program?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:45:44

3K+ Views

Whenever we issue a COMMIT statement, all the open cursors will get closed. This is a very common case when we have to frequently use the commit statement after a UPDATE while working with a cursor. In this case we can use the “WITH HOLD” clause during the cursor declaration.The ... Read More

What is the purpose and usage of “WHERE CURRENT OF” clause in a COBOL-DB2 program?

Mandalika

Mandalika

Updated on 15-Sep-2020 10:42:45

6K+ Views

The “WHERE CURRENT OF” clause will place the exclusive lock on the row once the UPDATE statement is executed. The “WHERE CURRENT OF” clause will point to the most recently fetched row of the cursor.We can update the rows in cursor using “WHERE CURRENT OF” in the following way.CURSOR definition.EXEC ... Read More

Advertisements