View previous topic :: View next topic |
Author |
Message |
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Mon Apr 13, 2009 3:39 pm Post subject: Defining CHAR field of 300 length? |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Mon Apr 13, 2009 3:41 pm Post subject: |
|
|
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 |
|
 |
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Mon Apr 13, 2009 4:02 pm Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Mon Apr 13, 2009 6:05 pm Post subject: |
|
|
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).
- select into the varchar group item declared by the dclgen
- 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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Thu Apr 16, 2009 10:56 am Post subject: |
|
|
Thank you All  _________________ Tx
Digger |
|
Back to top |
|
 |
|
|