Mandalika has Published 470 Articles

How will the COBOL-DB2 program behave when there is a mismatch between the host variable and number of columns in the SELECT statement?

Mandalika

Mandalika

Updated on 14-Sep-2020 14:44:03

712 Views

In case there is a mismatch in the number of columns and number of host variables, the query will fail. There are two ways in which we can detect this condition.The SQLWARN3 field of SQLCA will get the value as ‘W’ in case there is a mismatch.In some installations the ... Read More

How does DCLGEN utility accommodate NULL host variable for VARCHAR(n) data type?

Mandalika

Mandalika

Updated on 14-Sep-2020 14:39:55

2K+ Views

The DB2 column can store NULL value if it is explicitly not defined with the ‘NOT NULL’ option. However, COBOL does not have any NULL concept. In order to handle these NULL values, COBOL programs use spaces for character columns and zeros for integer columns having NULL value.However, the main ... Read More

Convert DECIMAL(7,3) into equivalent COBOL host variable PIC form.

Mandalika

Mandalika

Updated on 14-Sep-2020 14:30:09

1K+ Views

The formula for converting DECIMAL DB2 data type to COBOL equivalent is−DECIMAL(p,q) = PIC S9(p-q)V(q). Where V indicates implied decimal.The DECIMAL(7,3) can take a sample value as 7861.237 and this can be converted to COBOL equivalent as PIC S9(7-3)V(3) = PIC S9(4)V(3).

What are the COBOL host variable equivalent for various DB2 data types?

Mandalika

Mandalika

Updated on 14-Sep-2020 14:28:07

943 Views

The host variables are used to transfer the data from DB2 to program and vice versa.For each DB2 table column we have a COBOL equivalent host variable defined. The host variables can be generated automatically using the DCLGEN utility or we can explicitly give the host variables in the working ... Read More

What are the default values used by DB2 for various data types?

Mandalika

Mandalika

Updated on 14-Sep-2020 14:21:06

1K+ Views

DB2 provides a facility to insert a default value in case the user does not give any value for the column. For each DB2 data type there is a fixed default value which will be assigned to the column (which was defined with ‘DEFAULT’ parameter during table creation) if the ... Read More

What is NULL check and insertion rule in a DB2 table?

Mandalika

Mandalika

Updated on 14-Sep-2020 14:06:49

690 Views

Null in DB2 is defined as nothing. It is an unknown value. If we want to restrict NULL value in any column then the column should be defined with the “NOT NULL” parameter in CREATE TABLE.The “NOT NULL” will force the user to enter a value for the column. However, ... Read More

What is CASCADE rule for the foreign key on one table referencing to another table?

Mandalika

Mandalika

Updated on 14-Sep-2020 13:57:08

3K+ Views

The foreign key is used to establish a referential constraint between the child table(in which column is defined as foreign key) and parent table (in which foreign key of the child table becomes primary key). For example if we have an ORDER table in which foreign key is defined as ... Read More

What is the definition and usage of alternate key in a DB2 table?

Mandalika

Mandalika

Updated on 14-Sep-2020 13:52:07

657 Views

The DB2 table contains a number of columns whose value will remain unique in the entire table. Among these multiple columns only one column is selected as the primary key and the remaining keys are known as candidate keys.We can declare any candidate key as an alternate key. Which means ... Read More

What is a use of SQLWARN3 in a SQLCA? Explain with the help of a practical example?

Mandalika

Mandalika

Updated on 14-Sep-2020 13:40:22

308 Views

The SQLWARN3 field in SQLCA is used to detect the condition wherein the number of the resultant columns is greater than the number of host variables given in the query of a COBOL-DB2 program. The SQLWARN3 is a 1 byte field, which contains the value ‘W’when there is mismatch in ... Read More

How to truncate trapping of a DB2 column data when assigned to a host variable

Mandalika

Mandalika

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

215 Views

There are situations in which DCLGEN members are not used and the host variables declarations are done explicitly in the working storage section. However, due to these explicit declarations there are chances of human errors. One such error is declaring incorrect data length of COBOL equivalent host variables.For example, the ... Read More

Advertisements