MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Defining CHAR field of 300 length?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Mon Apr 13, 2009 3:39 pm    Post subject: Defining CHAR field of 300 length? Reply with quote

Hi All,

I'm trying to prepare the table definition using "CREATE TABLE" Command using the copybook as the reference in my test region

The copybook has a field shown below as part of the conversion project:
05 HTSKK PIC X(300).

I've defined this field in the DB2 def: as

HTS_KK CHAR(300)

and when tried to execute the 'CREATE TABLE' command its showing the SQLCODE as:
Code:

DSNT408I SQLCODE = -060, ERROR:  INVALID LENGTH SPECIFICATION : 300


But as per the manual its mentioned as

Code:

CHAR(n)   -
01 name PIC X(n). - Fixed-length character string

VARCHAR(n) 
01 name.
49 length PIC S9(4) COMP-5.
49 name PIC X(n).
 
1<=n<=32 672
 Variable-length character string


I think a char field can be defined maximum upto 254 (correct me if I'm wrong)
How can I define this field ? Please clarify?
_________________
Tx
Digger
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Apr 13, 2009 3:41 pm    Post subject: Reply with quote

VARCHAR(n)
01 name.
49 length PIC S9(4) COMP-5.
49 name PIC X(n).
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Mon Apr 13, 2009 4:02 pm    Post subject: Reply with quote

Hi Dick,

But the existing copybook is not having with the length and name fields. (49 level)

Is there any way I can define the field with length 300 in the DB2 definition - 'CREATE TABLE'

Thank you
_________________
Tx
Digger
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Apr 13, 2009 6:05 pm    Post subject: Reply with quote

yeah,

your dclgen will have the two 49 levels under the group item declaration for the varchar field:
  • the length field
  • and the pic x(300) text field.


your copybook can stay just a pic x(300).

  1. select into the varchar group item declared by the dclgen
  2. then move with ref mod the 49-level text from the dclgen to the pre-spaced pic x(300) field in your copybook.

use the length field (49-level) from the dclgen as your ref mod length.

Does not matter if your copybook has a length field.
you don't need it.
you have the length field (49 level) in the dclgen.
you can not create the dclgen without it.

by the way... selecting into copybooks not made from the dclgen is really poor practice.

if you work in a shop that allows the idiot practice of not using dclgen'd copybooks as host variables, then define in your working storage:
Code:

01  varchar-field-to-be-referenced-in-the-into-statement
    49  length-of-varchar-field      pic s9(4) binary. 
    49  varchar-text-field           pic x(300).


better check on the real pic clause for the length,
because I have never be so stupid as to use host variables other than dclgen'd copybooks,
so I don't know without looking it up.

edited twice, since it is late and I keep making errors in this post.
_________________
Dick Brenholtz
American living in Varel, Germany


Last edited by dbzTHEdinosauer on Mon Apr 13, 2009 6:15 pm; edited 2 times in total
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Mon Apr 13, 2009 6:11 pm    Post subject: Reply with quote

MFdigger,

The largest CHAR column you can create in z/OS Db2 is 255 bytes

Version 9 limits

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQK10/A.0?DT=20070125023435#TBLLIMSTR

Version 8 limits

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQJ12/A.0?DT=20050325102208#TBLLIMSTR


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Thu Apr 16, 2009 10:56 am    Post subject: Reply with quote

Thank you All Laughing
_________________
Tx
Digger
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group