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

Corresponding record format of COUNT(*) in db2


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

New User


Joined: 14 Dec 2005
Posts: 3

PostPosted: Wed Dec 14, 2005 1:00 pm
Reply with quote

Hi Friends,

I have written a COBOL program containing embedded DB2 SQL. The SQL is given below,

EXEC SQL
SELECT COUNT(*) INTO :WS-COUNT FROM VM_DATA
END-EXEC.

Now while i am trying to execute the program it is showing error because of the record format of the variable of WS-COUNT. I have tried with the following options,

01 WS-COUNT pic x(18)
- If I use this one then it will show error during the run time saying that record format is not same.

01 WS-COUNT pic 9(18) COMP
- If I use this one then it will show error during the compile time saying that undefinied type for WS-COUNT

01 WS-COUNT pic 9(18) COMP-3
-If I use this one then it will show error during the compile time saying that undefinied type for WS-COUNT

So I need your help to solve this problem. Can anybody please tell me what should be the format for the variable WS-COUNT?

I am waiting for your replies.

Thanks,
Joney Biswas
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Dec 15, 2005 12:14 am
Reply with quote

Define WS_COUNT as PIC S9(11) comp-3.
Back to top
View user's profile Send private message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Thu Dec 15, 2005 2:38 am
Reply with quote

hi

use the following code

EXEC SQL
SELECT DIGITS(COUNT(*)) INTO :WS-COUNT FROM VM_DATA
END-EXEC.

and you can define ws-count as numeric...
Back to top
View user's profile Send private message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Thu Dec 15, 2005 2:47 am
Reply with quote

hi joney

ignore my previous mail. for the sql to rin you cab define the host variable as PIC S9(09) COMP. Think this should also work. If not then you can use my previous reply
Back to top
View user's profile Send private message
joney_biswas

New User


Joined: 14 Dec 2005
Posts: 3

PostPosted: Fri Dec 16, 2005 10:08 am
Reply with quote

i defined the ws-count as like this

01 ws-count pic s9(11) comp-3.

and it worked fine. thanks for all of your supports.

Thanks,
Joney Biswas
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top