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

Using Count(*) query in Cobol program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 1353
Location: Israel

PostPosted: Wed Jun 15, 2011 12:03 am
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: 1353
Location: Israel

PostPosted: Wed Jun 15, 2011 7:08 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts To get the count of rows for every 1 ... DB2 3
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top