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

Multi row fetch for a VARCHAR


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

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Tue Aug 26, 2008 12:22 pm
Reply with quote

Hi All,

I am doing a multi row fetch from a table which has got a VARCHAR field of 255 maximum lenght. Now I am having a problem, like I am getting only lenth part populated for first occurance of the VARCHAR data. What happens is length part gets pushed into the data part by one byte, for all the remining occurance of this VARCHAR field alone. and lenth is not getting populated correctly!

Code:
Code:
 05  MY-FIELD           OCCURS 100 TIMES. 
   49  MY-FIELD-LENGTH         PIC S9(04) COMP.
   49  MY-FIELD-DATA            PIC  X(255). 

I am fetching into var MY-FIELD, the VARCHAR field. Can any body help be with the proble here. I have shown the lenth being entering into the data part below in hex:
Code:
 TESTDATA-11
0ECEECCEC6FF
B35234131011


Looking forward to your suggestions!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 26, 2008 1:53 pm
Reply with quote

what does your CURSOR DECLARE and FETCH look like?
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Mon Sep 01, 2008 12:19 pm
Reply with quote

Try SYNC with the length host variable.

05 MY-FIELD OCCURS 100 TIMES.
49 MY-FIELD-LENGTH PIC S9(04) COMP SYNC.
49 MY-FIELD-DATA PIC X(255).
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Wed Sep 03, 2008 5:27 pm
Reply with quote

Thanks a lot Umesh!

It worked out icon_biggrin.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 03, 2008 6:24 pm
Reply with quote

Umesh,

that is definitely a keeper.
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 Fetch data from programs execute (dat... DB2 3
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts Selective extract of multi-record-typ... SYNCSORT 4
Search our Forums:

Back to Top