- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is COBOL host variable equivalent for various DB2 data types?
Problem: How will the COBOL-DB2 program behave when there is a mismatch between the host variable and number of columns in the SELECT statement?
In case there is a mismatch in the number of columns and number of host variables, the query will fail. For example, if we have used the below query in a COBOL-DB2 program which processes the ORDERS DB2 table.
EXEC SQL SELECT ORDER_ID, ORDER_AMOUNT, ORDER_DATE, ORDER_STATUS INTO :WS-ORDER-ID, :WS-ORDER-AMOUNT, :WS-ORDER-DATE, FROM ORDERS WHERE ORDER_DATE = ‘2020-09-15’ END-EXEC
There is a mismatch in the number of columns and host variables. There are a total 4 columns used in the SELECT statement and for them only 3 host variables are used. In this case the query will fail and 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 SQLCODE field for SQLCA gets the error code as -804 when there is a mismatch.
We can use IF condition to check the value in SQLWARN3 or SQLCODE and direct the program processing accordingly.
Following is an example.
IF SQLWARN3 = ‘W’ PERFORM X00-ABEND-SECTION ELSE PERFORM A100-SELECT-RESULT END-IF
- What are the COBOL host variable equivalent for various DB2 data types?
- Convert DECIMAL(7,3) into equivalent COBOL host variable PIC form.
- What are the default values used by DB2 for various data types?
- What are COBOL equivalents of DB2 data types SMALLINT, INTEGER and DECIMAL?
- What are COBOL equivalents of DB2 data types CHAR, DATE, TIME and TIMESTAMP?
- What is the usage and purpose of DCLGEN and host variables used in COBOL-DB2 program
- How to truncate trapping of a DB2 column data when assigned to a host variable
- What are various Text data types in Python pandas?
- How will the COBOL-DB2 program behave when there is a mismatch between the host variable and number of columns in the SELECT statement?
- How does DCLGEN utility accommodate NULL host variable for VARCHAR(n) data type?
- What are the various techniques for data extraction?
- What are the various tools for Data Warehouse Quality?
- How to precompile a COBOL-DB2 program?
- What is Elementary Data Types?
- How to verify NULL value in DB2 column data using COBOL paragraph?