|
View previous topic :: View next topic
|
| Author |
Message |
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
Hi,
i'm trying to read a database field in cobol program. The DB2 filed is declared as Varchar with the length 32000, when i read this column through a cobol program it is displaying spaces where as the table has the data.
is there any compiler option which we need to change because the varchar length is more than 255?
Thanks in Advance,
Srinath D |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Compiler option? No.
Can you show your code, please. Data definition, code from the procedure division using the data. Please use the Code button (above the input box) to preserve spacing. Highlight text, click code, click preview, correct if necessary. Please copy/paste to avoid typos. |
|
| Back to top |
|
 |
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
Hi Bill,
Code is somewhat like this:
01 WS-TEXT.
49 WS-TEXT-LEN PIC S9(4) COMP.
49 WS-TEXT-FIELD PIC X(32000).
SELECT COLUMN1
INTO :WS-TEXT
FROM TAB1
DISPLAY ‘WS-TEXT : ‘WS-TEXT
DISPLAY ‘WS-TEXT-LEN : ‘WS-TEXT-LEN
DISPLAY ‘WS-TEXT-FIELD : ‘WS-TEXT-FIELD
OUTPUT:
WS-TEXT :
WS-TEXT-LEN : 0000
WS-TEXT-FIELD :
Problem is we are getting spaces in the fields. I tried using TRUNC(BIN) and TRUNC(OPT) Option as well.
Thanks
Srinath D |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Interesting. I've never displayed 32000 bytes at once before. I assume you mean
| Quote: |
OUTPUT:
WS-TEXT :
Then several kilometres down the listing
WS-TEXT-LEN : 0000
WS-TEXT-FIELD :
then another few kilometres
|
When you display WS-TEXT, WS-TEXT-LEN is within it, it can't be showing space. WS-TEXT-FIELD is also subordinate to WS-TEXT, so only actually "necessary" to display WS-TEXT-LEN and WS-TEXT-FIELD.
What data are you expecting in WS-TEXT-FIELD?
I'm just blindly assuming you've defined correctly for receiving a VARCHAR in your Cobol program, as I don't know myself. Have you? |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
try changing
01 WS-TEXT
to be a subordinate element under a different lvl-01. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
| srinathds83 wrote: |
| Code is somewhat like this: |
also,
somewhat is BS.
computer programming is a very strict and precise discipline.
if you still have problems, after implementing my suggestion,
then copy&paste - using CODE tags (here is how to use code tags)
your exact- Host variable definitions
- the ddl for the DECLARE Table
- imbedded SQL
by the way, what is the SQL code after the SELECT? |
|
| Back to top |
|
 |
|
|