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

SQLCODE=-122


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

New User


Joined: 31 Jul 2007
Posts: 1
Location: New Delhi

PostPosted: Wed Oct 13, 2010 7:55 pm
Reply with quote

Hi!

The following query is returning SQLCODE=-122. Do I need to add all the columns that I am SELECTing in the GROUP BY clause?

SELECT C20.PRSN_INTN_ID
,SUM(C20.SMRY_BAL_UT)
,C20.SMRY_THRU_PRCS_DT
,VALUE (AAA.UTAFTER,0)
,A31.PLAN_ID
,A31.ACCT_ID
,A31.FUND_ID
,A31.SF_ID
,A22.EM_CLNT_ID
,VALUE (A26.ORG_CD,' ')
,VALUE (A04.EMPL_STAT_CD,' ')
,VALUE (A56.PLAN_STAT_CD,' ')
FROM PRSN_SMRY_HBAL C20

LEFT JOIN
(SELECT PRSN_INTN_ID
,HBAL_ID
,SUM(BAL_UT) AS UTAFTER
FROM PRSN_HBAL A52A
WHERE PRCS_DT > :Host-EfEndDt
GROUP BY PRSN_INTN_ID
,HBAL_ID
) AAA
ON AAA.PRSN_INTN_ID = C20.PRSN_INTN_ID
AND AAA.HBAL_ID = C20.HBAL_ID

INNER JOIN
HBAL A31
ON A31.HBAL_ID = C20.HBAL_ID

INNER JOIN
PRSN A22
ON A22.PRSN_INTN_ID = C20.PRSN_INTN_ID

LEFT JOIN
EE_ORG A26
ON A26.PRSN_INTN_ID = C20.PRSN_INTN_ID
AND A26.ORG_CAT_ID = :A26-ORG-CAT-ID
AND EE_ORG_EFBEGDT <= :Host-EfEndDt
AND EE_ORG_EFENDDT >= :Host-EfEndDt

LEFT JOIN
EE_EMPL_CAT A04
ON A04.PRSN_INTN_ID = C20.PRSN_INTN_ID
AND A04.EMPL_CAT_ID = :A04-EMPL-CAT-ID
AND EE_EMPLCAT_EFBEGDT <= :Host-EfEndDt
AND EE_EMPLCAT_EFENDDT >= :Host-EfEndDt

LEFT JOIN
PP_STAT A56
ON A56.PRSN_INTN_ID = C20.PRSN_INTN_ID
AND A56.PLAN_STAT_CAT_ID = :A56-PLAN-STAT-CAT-ID
AND EE_EMPLCAT_EFBEGDT <= :Host-EfEndDt
AND EE_EMPLCAT_EFENDDT >= :Host-EfEndDt

GROUP BY AAA.HBAL_ID
,C20.PRSN_INTN_ID
,C20.SMRY_BAL_UT

ORDER BY A31.PLAN_ID

WITH UR
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: Wed Oct 13, 2010 8:38 pm
Reply with quote

Hello and welcome to the forum,

At the top of the page is a link to "IBM Manuals". Down the list are some DB2 Messages and Codes documentation. These contain explanations for SQL return codes.

For the -122 read here:
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/dsnmcj10/2.1.6.28

If you find something in the manual that is not clear, post what you found and your doubt. Someone will be able to clarify.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Oct 15, 2010 1:45 pm
Reply with quote

yes, unless you use the same trick as you did for subselect AAA

Code:
...
FROM (select PRSN_INTN_ID,SMRY_THRU_PRCS_DT
           , sum(C20.SMRY_BAL_UT) as UTbefore  from PRSN_SMRY_HBAL
      group by  PRSN_INTN_ID,SMRY_THRU_PRCS_DT) C20

LEFT JOIN ...
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 SQLCODE = -122 while using the scalar... DB2 4
No new posts SQLCODE = -16002 when using XMLEXISTS DB2 1
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts SQLCODE=-204 SQLSTATE=42704 DB2 4
No new posts Getting sqlcode 805 while executing R... DB2 10
Search our Forums:

Back to Top