VARCHAR in DB2

db2 sql interview questions

Moderator: Moderator Group

Post Reply
Kamini R
Member
Posts: 6
Joined: Thu Jul 09, 2009 2:26 pm
Location: Chennai

VARCHAR in DB2

Post by Kamini R » Sat Nov 12, 2011 8:48 am

Hi,

Pls let me know how to insert a varchar into a table.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sat Nov 12, 2011 12:28 pm

For SPUFI:

Suggest you try an INSERT and put the value in quotes (just like any character data).

In a program, declare the host variable as a group item with a length and the data as elementary items. Use level 49 for the length and data definitions.
Have a good one

fredrick andrews
Member
Posts: 15
Joined: Thu Feb 23, 2012 6:55 am

Post by fredrick andrews » Thu Feb 23, 2012 8:34 am

10 XYZ.
49 XYZ-LEN PIC S9(4) USAGE COMP.
49 XYZ-TEXT PIC X(100).

XYZ-LEN is the length of the dataitem and XYZ-TEXT is the actual data-item.

HTH

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Feb 23, 2012 9:41 am

Fredrick Andrews,

if you are going to provide code,
learn to use BB-code,
so that the code retains the indentation that all good coders employ when writing a program.

when you use the PREVIEW button, to preview your post,
the BB-CODE butttons will be available.
otherwise, you can code the mark-up language yourself (when you have learned the syntax).

Code: Select all

10 ACCOUNT-DETAILS-VARCHAR.
   49 ACCOUNT-DETAILS-LEN PIC S9(4) USAGE COMP.
   49 ACCOUNT-DETAILS-TEXT PIC X(100). 
and we encourage people to use meaningful Reference Names,
even in examples.
they can be up to 30 characters long.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

fredrick andrews
Member
Posts: 15
Joined: Thu Feb 23, 2012 6:55 am

Post by fredrick andrews » Thu Feb 23, 2012 7:09 pm

Roger!


:D Thanks!

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