Found 6705 Articles for Database

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

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

311 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 number of columns returned by the query and number of host variables used.We can enquire the status of SQLWARN3 using IF or EVALUATE statements as in the below exampleA010-CHECK-ORDER. EXEC SQL    SELECT ORDER_DATE,          ORDER_TOTAL       INTO :ORDER-DATE,       FROM ORDERS   ... Read More

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

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

217 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 host variable should have been declared as PIC X(24) but it was declared as PIC X(14) by mistake. In this case when the data transfer takes place from DB2 to COBOL program, the column data might get truncated due to the shorter length of the receiving host variable.We can detect ... Read More

How will the COBOL-DB2 program behave if the DCLGEN member is not included?

Mandalika
Updated on 14-Sep-2020 11:42:21

2K+ Views

The DCLGEN member contains two important sets of data.The table structure containing definitions of all the columns present in the table.The host variable declaration in equivalent COBOL data types.Including the DCLGEN member is not mandatory until we explicitly give the host variables declaration in the working storage section. But it is always considered as a good coding practice to include a DCLGEN member because it also contains the table structure using which the pre-compiler can perform the query column validation. Although, the query column validation is optional for the pre-compiler but it gives us possible errors in the precompilation stage ... Read More

What is the purpose and usage of SQLCODE within the SQLCA in a COBOL-DB2 program

Mandalika
Updated on 14-Sep-2020 11:24:41

2K+ Views

The SQLCODE field of SQLCA is used to get the return code for the last executed SQL query from DB2 to COBOL program. Below are the range of return codes which SQLCODE field can take along with their significance.SQLCODE = 0 → Query executed successfully without any issue.SQLCODE > 0 → There was a warning issued while executing the query.SQLCODE < 0 → There was an error occurred while executing the query.Below is the sample paragraph where the usage of SQLCODE is demonstrated.A010-CHECK-ORDER. EXEC SQL    SELECT ORDER_DATE       INTO :ORDER-DATE,       FROM ORDERS     ... Read More

What will be the result if SQLCA is not included in a COBOL-DB2 program?

Mandalika
Updated on 14-Sep-2020 11:18:22

2K+ Views

The SQLCA helps in the communication between DB2 and COBOL-DB2 program. The SQLCA has multiple fields which gives us different information regarding the last executed SQL query.The SQLCA is mandatory in a COBOL-DB2 program. However, if we do not give the SQLCA using the INCLUDE statement then the program compilation will fail and we will get the below error in the logs−“SQLCA is not defined as a data-name”

What are COBOL equivalents of DB2 data types CHAR, DATE, TIME and TIMESTAMP?

Mandalika
Updated on 14-Sep-2020 11:15:06

2K+ Views

The DATE, TIME and TIMESTAMP DB2 data types occupy 4, 3 and 10 bytes respectively. The memory occupied by the CHAR data types is occupied as per the size given. Below table shows the equivalent COBOL data types for CHAR, DATE, TIME and TIMESTAMP.DB2 data typeDB2 BytesCOBOL equivalentCOBOL bytesCHAR(z)zPIC X(z)zDATE4PIC X(10)10TIME3PIC X(8)8TIMESTAMP10PIC X(26)26

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

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

4K+ 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

2K+ 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

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
Updated on 14-Sep-2020 10:55:38

814 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

Advertisements