Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Using Count(*) query in Cobol program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
praveena avaluru

New User


Joined: 29 Sep 2010
Posts: 9
Location: bangalore

PostPosted: Tue Jun 14, 2011 2:07 pm    Post subject: Using Count(*) query in Cobol program
Reply with quote

Hi
I have 2 variables
WS-count is declared as a S9(04) Comp-3 and
the value in WS-DUPLICATE is 07%

The table has the following rows
COLUMN1
07
078
0781
I have a query in the cobol program as

EXEC SQL
SELECT COUNT(*)
INTO :WS-COUNT
FROM TABLE
WHERE
COLUMN1 LIKE :WS-DUPLICATE
END-EXEC

The result ( ws-count) is 2 and not 3.

When i run this query in spufi the result is 3

Do i have to take any care while running a Count(*) in cobol ??

Regards
Praveena Avaluru
Back to top
View user's profile Send private message

nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Tue Jun 14, 2011 2:31 pm    Post subject: Re: Using Count(*) query in Cobol program
Reply with quote

Did you check the value of WS-DUPLICATE just before the query is executed?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jun 14, 2011 4:38 pm    Post subject:
Reply with quote

what is the datatype of COLUMN1?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1224
Location: Israel

PostPosted: Wed Jun 15, 2011 12:03 am    Post subject:
Reply with quote

That's because in spufi you do:
Code:
WHERE COLUMN1 LIKE '07%'
and in cobol you do
Code:
WHERE COLUMN1 LIKE '07%      '

Note the spaces after the % in cobol (number of spaces according to PIC of WS-DUPLICATE)
0781 does not fit in your WHERE request.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1224
Location: Israel

PostPosted: Wed Jun 15, 2011 7:08 pm    Post subject: Reply to: Using Count(*) query in Cobol program
Reply with quote

Did you solve your problem, and how?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us