Use SQLCA in a COBOL DB2 Program

Mandalika
Updated on 14-Sep-2020 10:49:17

4K+ Views

SQLCA stands for SQL-Communication Area. It is a medium through which DB2 can communicate with the COBOL program. In a typical COBOL-DB2 program, there are many SQL statements used. The main purpose of SQLCA is to inform the COBOL program about the status and other details of the most recently executed SQL query.The SQLCA has a total length of 136 bytes and it is composed of various fields like SQLCODE, SQLERRD, SQLWARN, etc. Each of these fields give specific details of the last executed SQL query.For example, SQLCODE returns the DB2 error code (if any), SQLWARN returns the warning issued ... Read More

What is Non-Clustered Index in DB2

Mandalika
Updated on 14-Sep-2020 10:47:33

591 Views

The non-clustered index is just the opposite of the clustered index. In a non-clustered index, it is not necessary that the data rows having similar index keys should reside in the same page. This index is suitable if we have to traverse through the table.For example, if we take the scenario where index keys of the table are the whole number - 2, 12, 14, etc. Then the non-clustered index structure would look like below−

Clustered Index in DB2 Explained with Practical Example

Mandalika
Updated on 14-Sep-2020 10:44:23

1K+ Views

In a CLUSTERED INDEX of a DB2 table, the data rows (table rows) with the similar index keys are stored in the same page. For example, If we have 4 index keys - T5623, T5611, Z9786 and Z9078. So the data rows with similar keys T5623 and T5611 will be stored in the same page and other similar keys Z9786 and Z9078 will be stored together on the other page.The Clustered index structure has 2 types of pages i.e., Index page and data page. The index page stores all the index key values and points to the data page so ... Read More

Update Incorrect Timestamp Format in a DB2 Table

Mandalika
Updated on 14-Sep-2020 10:39:59

416 Views

As per the standard DB2 definitions, timestamp holds 10 bytes in DB2 storage and 26 bytes in corresponding COBOL storage (PIC X(26)). It is in the format YYYY-MM-DDHH. MM.SS.NNNNNN. Where, YYYY:- Year | MM:- Month | DD:- Date | HH:- Hour | MM:- Minutes | SS:- Seconds | NNNNNN:- MillisecondsAs per the scenario given in the question, the timestamp is “2020-07-01 23:14”. Clearly, the format of the timestamp is incorrect as the correct format is YYYY-MM-DDHH. MM.SS.NNNNNN. In this case if we will try to insert this incorrectly formatted timestamp in a DB2 table column which is defined as timestamp ... Read More

Update DB2 Table with Duplicate Primary Key

Mandalika
Updated on 14-Sep-2020 10:29:11

941 Views

To maintain the integrity of a DB2 table the primary key is always unique in the entire table. For example, if we have a DB2 table ORDERS which stores all the orders and the primary key of the table is column ORDER_ID. Then there can be only a single row having a particular order id. This will be useful to identify an order distinctly.If we try to insert or update a row in a DB2 table having duplicate primary key using a COBOL-DB2 program, we will get DB2 error code -803. As per the IBM documentation - 803 error code ... Read More

Retrieving Elements from Collection in Java using Enumeration and Iterator

AmitDiwan
Updated on 14-Sep-2020 09:41:53

238 Views

EnumerationIterator doesn’t have the option of eliminating elements from the collection, whereas an iterator has this facility. An additional disadvantage of using EnumerationIterator is that the name of methods associated with EnumerationIterator is difficult to remember.ExampleFollowing is an example − Live Demoimport java.util.Vector; import java.util.Enumeration; public class Demo {    public static void main(String args[]) {       Vector day_name = new Vector();       day_name.add("Tuesday");       day_name.add("Thursday");       day_name.add("Saturday");       day_name.add("Sunday");       Enumeration my_days = day_name.elements();       System.out.println("The values are ");       while (my_days.hasMoreElements())     ... Read More

Retrieve Elements from Collection Using ListIterator in Java

AmitDiwan
Updated on 14-Sep-2020 09:39:05

238 Views

Following is an example to retrieve elements from Collection in Java-ListIterator −Example Live Demoimport java. util.* ; public class Demo {    public static void main(String args[]) {       Vector my_vect = new Vector();       my_vect.add(56);       my_vect.add(78);       my_vect.add(98);       my_vect.add(34);       ListIterator my_iter = my_vect.listIterator();       System.out.println("In forward direction:");       while (my_iter.hasNext())       System.out.print(my_iter.next()+" ") ;       System.out.print("In backward direction:") ;       while (my_iter.hasPrevious())          System.out.print(my_iter.previous()+" ");    } }OutputIn forward direction: 56 78 ... Read More

Retrieve Elements from Collection in Java using Iterator

AmitDiwan
Updated on 14-Sep-2020 09:36:16

372 Views

Following is an example to retrieve elements −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       HashSet my_hs = new HashSet() ;       my_hs.add("Joe");       my_hs.add ("Rob");       Iterator my_it = my_hs.iterator();       System.out.println("The elements are : ");       while (my_it.hasNext())          System.out.println(my_it.next());    } }OutputThe elements are : Joe RobA class named Demo contains the main function, which defines a HashSet collection. Elements are added to this collection using the ‘add’ function. An iterator is defined, and the ... Read More

Retrieve Elements from Collection in Java Using For-Each Loop

AmitDiwan
Updated on 14-Sep-2020 09:34:04

330 Views

The ‘for-each’ loop is used to iterate over a set of elements that is stored in a data structure.Syntaxfor (element e: collection) {    System.out.println(e); }ExampleFollowing is an example − Live Demopublic class Demo {    public static void main(String[] args) {       int[] my_vals = {5, 67, 89, 31, -1, 2, 0};       int sum = 0;       for (int number: my_vals) {          sum += number;       }       System.out.println("The sum is " + sum);    } }OutputThe sum is 193A class named Demo contains the ... Read More

Reflection Array Class in Java

AmitDiwan
Updated on 14-Sep-2020 09:26:40

589 Views

The array class present in java.lang.reflect package belong to the Java reflection class. The Java Reflection class provides static methods, and these methods can be used to create and access Java arrays in a dynamic manner. This class is final, and this means it can’t be changed or even instantiated. The methods present inside this class can be used with the help of the class name itself.The methods present in java.util.Arrays.class can be used to work with arrays, and the java.lang.reflect.Array class contains methods that help in creating and working with Java arrays in a dynamic manner.The java.lang.reflect.Array class is ... Read More

Advertisements