
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to truncate trapping of a DB2 column data when assigned to a host variable
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 such situations using SQLWARN1 field of SQLCA. The SQLWARN1 is 1 byte field which contains the value ‘W’ if there is any truncation while data transfer. We can make use of this field as below.
A010-CHECK-ORDER. EXEC SQL SELECT ORDER_DATE INTO :ORDER-DATE, FROM ORDERS WHERE ORDER_ID = :ORDER-ID END-EXEC EVALUATE SQLWARN1 WHEN ‘W’ DISPLAY ‘THE ORDER DATE WAS TRUNCATED’ WHEN OTHER DISPLAY ‘ORDER DATE IS ‘ ORDER-DATE
- Related Questions & Answers
- What is COBOL host variable equivalent for various DB2 data types?
- What are the COBOL host variable equivalent for various DB2 data types?
- 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 to store a NULL value in a particular column of a DB2 table using COBOL-DB2 program?
- How to create a categorical variable using a data frame column in R?
- How to create a column with binary variable based on a condition of other variable in an R data frame?
- What happens when a subclass object is assigned to a superclass object in Java?
- How to truncate a file in Java?
- How to truncate a file in C#?
- Must you define a data type when declaring a variable in JavaScript?
- How to create a frequency column for categorical variable in an R data frame?
- How to verify NULL value in DB2 column data using COBOL paragraph?
- How to convert a data frame into two column data frame with values and column name as variable in R?
- How does DCLGEN utility accommodate NULL host variable for VARCHAR(n) data type?
- Adding integers from a variable to a MySQL column?