Found 150 Articles for DB2

What are COBOL equivalents of DB2 data types SMALLINT, INTEGER and DECIMAL?

Mandalika
Updated on 14-Sep-2020 11:05:46

2K+ Views

The DCLGEN utility converts the table column from DB2 data types to host variables having equivalent COBOL data types. The SMALLINT and INTEGER is converted to COBOL signed numeric data types and DECIMAL is converted to COBOL signed numeric with implied decimal. Below are the equivalent COBOL data types for SMALLINT, INTEGER and DECIMAL.DB2 data typeDB2 BytesCOBOL equivalentCOBOL bytesSMALLINT2PIC S9(4) COMP2INTEGER4PIC S9(9) COMP4DECIMAL(x,y)INT(x/2)PIC S9(x-y)V9(y)INT(((p+q)/2) +1)

What will be the result if DCLGEN is given with COPY statement and not INCLUDE?

Mandalika
Updated on 14-Sep-2020 11:01:31

1K+ Views

The main difference between INCLUDE and COPY statement is the PDS member with INCLUDE statement is expanded during pre-compilation while the PDS member with COPY statement is expanded during compilation.Since the DCLGEN member contains column names of the table (table structure) it is necessary to expand it during the pre-compilation. This is because at the time of precompilation all the SQL statements are validated, placed in DBRM and finally replaced by appropriate COBOL calls.If the DCLGEN members are given with COPY statement instead of INCLUDE statement, then it will result in DB2 warnings during pre-compilation as the pre-compiler would not ... Read More

What is the usage and purpose of DCLGEN and host variables used in COBOL-DB2 program

Mandalika
Updated on 14-Sep-2020 10:58:02

3K+ Views

A COBOL-DB2 program can query/update/insert/delete data from multiple DB2 tables. However, in order to achieve this, we must fulfill two main conditions.Notify the structure of the DB2 table to the COBOL-DB2 program. This includes all the columns and data types of these columns.The respective host variables for each column. The host variables are used in the program logic to move the data from DB2 to program and vice versa. There is one host variable for every table column based on its data type. For example, for a table column with data type CHAR(2), there should be a host variable with ... Read More

What is a use of DSNTIAR? How will you implement it in a COBOLDB2 program?

Mandalika
Updated on 14-Sep-2020 10:55:38

455 Views

We use fields of SQLCA to enquire about the status of the most recently executed SQL query. The SQLCODE is one such field which can take the various values and each value indicates specific error code. For example, -180 error code represents incorrect timestamp format. However, in the logs we only get the error code and every time we have to refer to the IBM documentation to check the description of the error code.To overcome this problem, we use DSNTIAR. The DSNTIAR is an inbuilt utility which is provided by IBM to be used in a COBOL-DB2 program.This utility displays ... Read More

Implementation of common error-trapping logic for all SQL statements in program

Mandalika
Updated on 14-Sep-2020 10:52:41

134 Views

A COBOL-DB2 program can have multiple DB2 SQL statements. In order to implement the common error-trapping for all the SQL statements in a COBOL-DB2 program, we will use WHENEVER statement.The WHENEVER statement can direct the control to the error handling section or routine based on the value returned in SQLCODE field of SQLCA. For example, we can declare WHENEVER statement in COBOL-DB2 program as below−EXEC SQL    WHENEVER SQLERROR GOTO ERROR-ROUTINE END-EXECIn the above example, the SQLERROR parameter will be set only when the value of SQLCODE will be lesser than zero, which indicates that there was some error occurred ... Read More

How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?

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

2K+ 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? Explain with the help of practical example

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

324 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−

What is CLUSTERED INDEX in DB2? Explain with the help of practical example.

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

768 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

How to update of incorrect timestamp format in a DB2 table?

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

269 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

How to update DB2 table with a duplicate primary key?

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

564 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

Advertisements