Hi Everyone,
When run the same query form DB2 I could able to get the results but while trying it form java I get the error as Unexpected Token. Could anyone please let me know what is the issue in it.
Below is the query in java
Query qry = session.createQuery("SELECT appTrans.application_id, appTrans.trans_ts, appTrans.trans_status FROM APPLICATIONS_TRANS_DETAILS appTrans " +
"INNER JOIN (SELECT appTrans2.application_id, max(appTrans2.trans_ts) AS Column2 FROM APPLICATIONS_TRANS_DETAILS appTrans2 " +
"GROUP BY appTrans2.application_id) AS appTrans3 ON appTrans.application_id = appTrans3.application_id AND " +
"appTrans.trans_ts = appTrans3.Column2 where appTrans.application_id in(select App.APPLICATION_ID from APPLICATIONS As App " +
"where App.SKILL_ID in("+ skills.toString().substring(1,skills.toString().length()-1) + ") and App.USER_CNUM_ID='072725744' and " +
"App.LEVEL_ID in ("+levels.toString().substring(1,levels.toString().length()-1)+") order by skill_id) ORDER BY appTrans.application_id");
The generated query is
SELECT appTrans.application_id, appTrans.trans_ts, appTrans.trans_status
FROM SM.APPLICATIONS_TRANS_DETAILS appTrans INNER JOIN
(SELECT appTrans2.application_id, Max(appTrans2.trans_ts) AS Column2
FROM SM.APPLICATIONS_TRANS_DETAILS appTrans2
GROUP BY appTrans2.application_id) AS appTrans3 ON appTrans.application_id = appTrans3.application_id AND appTrans.trans_ts = appTrans3.Column2
where appTrans.application_id
in(select App.APPLICATION_ID from SM.APPLICATIONS As App where App.SKILL_ID in(121024,121025,121026,121027,121028,121029) and App.USER_CNUM_ID='072725744' and App.LEVEL_ID in (1, 2, 3)
order by skill_id)
ORDER BY appTrans.application_id
Thanks in advance
Madhava ram
|