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

Multiple Aggregate function in one query failed at cobol


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

New User


Joined: 11 Nov 2010
Posts: 22
Location: Mumbai

PostPosted: Sun May 19, 2013 7:36 pm
Reply with quote

Hi,

I am trying to run below query in Cobol,
Code:
Select Min(TimestampDiff(2,Char(D.LAST_UPD_TIMESTAMP-D.SETUP_TIMESTAMP))),
       Max(TimestampDiff(2,Char(D.LAST_UPD_TIMESTAMP-D.SETUP_TIMESTAMP))),
       Avg(TimestampDiff(2,Char(D.LAST_UPD_TIMESTAMP-D.SETUP_TIMESTAMP)))
From NUPG.TPGDLOG D, NUPG.TPGSLOG C   
WHERE C.MB_Unique_Id = D.MB_Unique_Id And                 
C.Receive_Timestamp > '2013-05-17-23.46.09.000000' And     
C.Receive_Timestamp < '2013-05-18-23.53.18.000000' And     
C.System_Id = 'Exceed' And                                 
D.Process_Name = 'PDF Archive' And                         
D.Process_Status = 'C'   
In Spufi it gave me proper output,
Same when I tried in cobol by defining host variables properly as below,
Code:
SELECT                                                     
MIN(                                                       
TimestampDiff(                                             
2,Char(D.LAST_UPD_TIMESTAMP - D.SETUP_TIMESTAMP)))         
INTO :WS-MIN-VALUE ,                                       
MAX(                                                       
TimestampDiff(                                             
2,Char(D.LAST_UPD_TIMESTAMP - D.SETUP_TIMESTAMP)))         
INTO :WS-MAX-VALUE ,                                       
AVG(                                                       
TimestampDiff(                                             
2,Char(D.LAST_UPD_TIMESTAMP - D.SETUP_TIMESTAMP)))         
INTO :WS-AVG-VALUE                                         
FROM TPGDLOG D,                                           
     TPGSLOG C                                             
WHERE C.MB_UNIQUE_ID = D.MB_UNIQUE_ID AND   
      C.RECEIVE_TIMESTAMP  > :WS-START-TS AND
      C.RECEIVE_TIMESTAMP  <= :WS-END-TS AND
      UPPER(C.SYSTEM_ID) = :WS-SYSTEM AND   
      D.PROCESS_NAME = 'PDF Archive' AND     
      D.PROCESS_STATUS = 'C'                 


Getting following error message,
IGYPS0226-E DSNH104I DSNHPARS LINE 158 COL 333 ILLEGAL SYMBOL "(". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: FROM , .


But when I tried with one aggregate function it compiled properly.

Host variable declaration are done as follow,
Code:
03       WS-MIN-VALUE        PIC S9(7)V9(2) COMP-3.
03       WS-MAX-VALUE        PIC S9(7)V9(2) COMP-3.
03       WS-AVG-VALUE        PIC S9(5)V9(2) COMP-3.
Please help
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon May 20, 2013 2:18 am
Reply with quote

What is wrong with using code tags? I find it difficult to read through what you posted. If you want help then help those who would help you by making your post more easily readable.
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: Mon May 20, 2013 7:29 am
Reply with quote

Hello,

Even though the sql has been Coded, the presentation is still not as readable as it could be. Please use Preview in the future to ensure the post is properly indented.

It may not matter, but there is no comma after INTO :WS-AVG-VALUE

Are multiple INTOs allowed? I don't know and have no way to test 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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top