Problem with Varchar



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Problem with Varchar

Postby Bebbe » Wed Jan 13, 2010 7:52 pm

Hey there.

I get an error message because I try to move something in a field which takes the value of an column of a DB2-Table. This is declared as VARCHAR. My Hostvariable is fixed with PIC X. So I have searched a bit and found something about 49 stages. But I don't know what and how to do. Has anybody an idea where I can find help to understand what I have to do, to use Hostvariables with VARCHAR definition?

thanks a lot.
Bebbe
 
Posts: 1
Joined: Wed Jan 13, 2010 7:35 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with Varchar

Postby BChat » Wed Jan 13, 2010 11:20 pm

Bebbe,

Its like
01 WS-VARCHAR.
49 WS-VARCHAR-LEN PIC S9(4) COMP.
49 WS-VARCHAR-TEXT PIC X(??).

?? is the size of the VARCHAR col

The usage will be like :WS-VARCHAR
like
SELECT A.VARCHAR INTO :WS-VARCHAR ....

In SELECT, the data will be put to into WS-VARCHAR-TEXT & the length of the of the data in WS-VARCHAR-LEN.

To INSERT/UPDATE you move the data to WS-VARCHAR-TEXT and its length into WS-VARCHAR-LEN and then use :WS-VARCHAR. Ideally you should put the actual length of the data in WS-VARCHAR-LEN so as to save storrage. But in most cases you will unfortunately find
MOVE LENGTH OF WS-VARCHAR-TEXT TO WS-VARCHAR-LEN but bad coding

Cheers,
BChat
BChat
 
Posts: 19
Joined: Thu Jun 11, 2009 8:20 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post