IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Display Varchar value in DB2 in cobol hostvariable ?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
diwakar_rao

New User


Joined: 04 Mar 2007
Posts: 14
Location: Chennai

PostPosted: Thu Apr 10, 2008 12:14 am
Reply with quote

Hi,

I have a DCLGEN declaration like this

DB2 declaration
empname VARCHAR(20)
---------------------------------------------------
cobol host variable declaration
01 emp.
05 hv-empname.
49 hv-emp-len PIC S9(4) COMP-2.
49 hv-emp-txt PIC X(20).
----------------------------------------------------
EXEC SQL DECLARE <cursorname> CURSOR FOR
SELECT empname from emp
END-EXEC.

then fetching the data

EXEC SQL FETCH <cursorname> INTO :hv-empname

My pbm is when i try displaying this hv-empname , i am getting <.<data in empname> (dot followed by data in empname)

Kindly update me how to display a VARCHAR db2 data in to host variable in cobol ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 10, 2008 12:17 am
Reply with quote

Hello,

You cannot "display" the group variable - the first field will nearly always contain one or more undisplayable values.

To see the name and not the "unprintable" data, try displaying hv-emp-txt.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 10, 2008 3:43 am
Reply with quote

Something like
DISPLAY hv-emp-len '*' hv-emp-txt(1:hv-emp-len) '*'
should get you what you want.....
Back to top
View user's profile Send private message
diwakar_rao

New User


Joined: 04 Mar 2007
Posts: 14
Location: Chennai

PostPosted: Thu Apr 10, 2008 9:25 am
Reply with quote

Thanks it is working now
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top