data type definition of db2 fields in cobol

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
parulkatiyar
Member
Posts: 1
Joined: Wed Feb 24, 2010 8:04 pm

data type definition of db2 fields in cobol

Post by parulkatiyar » Wed Mar 03, 2010 7:54 pm

how do we define datatype varchar(500) of db2 in cobol?

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Mar 05, 2010 2:40 pm

You define it this way:

Code: Select all

05 var-fld. 
   49 VARCHAR-LEN      PIC S9(004) COMP.
   49 VARCHAR-LEN-TEXT     PIC  X(500). 
If you are creating the field, you must move the TRUE length of the field to VARCHAR-LEN as well as moving the data to VARCHAR-LEN-TEXT. To retreive the data use a reference modified MOVE using VARCHAR-LEN as the length modifier.

I'd suggest you do some research before you use VARCHAR. There are some performance hits you can run into, as well as some processing peculiarities.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others