DB2 Articles

Page 9 of 13

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

Mandalika
Mandalika
Updated on 14-Sep-2020 5K+ 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
Mandalika
Updated on 14-Sep-2020 937 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
Mandalika
Updated on 14-Sep-2020 376 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
Mandalika
Updated on 14-Sep-2020 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

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

Mandalika
Mandalika
Updated on 14-Sep-2020 487 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
Mandalika
Updated on 14-Sep-2020 1K+ 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

Give the panel command to start a specific tablespace within a DB2 database.

Mandalika
Mandalika
Updated on 12-Sep-2020 207 Views

To start a specific tablespace within a DB2 database we can use below panel command.START DATABASE (DSNDB01) SPACENAM(TABSPAC1)Using the START DATABASE command, we can also start database and indexspace.

Read More

Give and explain the panel command to display all the components of DB2 database DSNDB01 along with their status?

Mandalika
Mandalika
Updated on 12-Sep-2020 192 Views

A database contains multiple components like tablespace, indexspace, index, tables, etc. We can find out all the components within the database using the below panel command.DIS DB(DSNDB01)

Read More

What are the ways to calculate DB2 database size using DB2 utility and other methods?

Mandalika
Mandalika
Updated on 12-Sep-2020 829 Views

There are multiple ways in which we can estimate the size of the DB2 database. Few of them are listed below−By using inbuilt get_dbsize_info function.By using DB2 active transaction logs.The size of the dataset which was used with UNLOAD utility can be checked.Table/Index dataUsing STOSPACE utility in JCL as below//STEP1 EXEC DSNUPROC //SYSIN DD * STOSPACE DATABASE DSNDB01 //*

Read More

How to repair a pending state of an index IDX1?

Mandalika
Mandalika
Updated on 12-Sep-2020 543 Views

The pending state is set when the image copy is required for the table space or when the INDEX is in rebuild status. In this case a COPY PENDING/ REBUILD PENDING flag is set. We can repair this state by using the below JCL step.//STEP010 EXEC DSNUPROC REPAIR SET INDEX IDX1 NORBDPENDThis utility can also be used to repair the tablespace. For this we can use the REPAIR SET TABLESPACE statement. This is followed by the name of index or tablespace.

Read More
Showing 81–90 of 122 articles
« Prev 1 7 8 9 10 11 13 Next »
Advertisements