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
 

 

Multiple Aggregate function in one query failed at cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Multiple Aggregate function in one query failed at cobol
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: 1756
Location: UK

PostPosted: Mon May 20, 2013 2:18 am    Post subject:
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

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon May 20, 2013 7:29 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts Unable to catalog a gdg dataset resid... Shovan JCL & VSAM 7 Fri Mar 24, 2017 2:24 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm


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