-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Converting Sql to Hql
PostPosted: Wed Nov 26, 2008 10:37 am 
Newbie

Joined: Wed Nov 26, 2008 9:57 am
Posts: 1
Location: India
Hi ,

Could you please give me the Hql to the below Sql.
Iam not able to Convert my Sql Code to Hql according to my Requirement.
First Please tell me that can we convert any given sql to hql ?Is it possible?.
Iam facing some issues with the below Sql Query not able to convert to HQL.
Here is the SQL Query.....

select A.RSI,B.RUN,A.RD,A.RNAME,A.AIND,A.RNUM,A.RSD,A.IE,A.RSSI,A.RECSTATIND,A.CC,
(select repturl from table3 where rptschdlinstance=B.RSI and to_char(run_tmstp,'DD-Mon-YYYY HH24:MI:SS')=B.RUN) REPTURL,
(select errordesc from table3 where rptschdlinstance=B.rsi and to_char(run_tmstp,'DD-Mon-YYYY HH24:MI:SS')=B.run) errordesc,
(select recordstatind from table3 where rptschdlinstance=B.rsi and to_char(run_tmstp,'DD-Mon-YYYY HH24:MI:SS')=B.run) recordstatind
FROM
(select
rsi.rptschdlinstance RSI,r.rept_def_id RD ,r.rept_name RNAME,r.archive_action_ind AIND,r.rept_num RNUM,
rsi.rept_schedule_desc RSD, rsi.is_external IE, rsi.rept_schedule_stat_ind RSSI ,rsi.record_stat_ind RECSTATIND,
rsi.client_comp_id CC from table1 r join table2 rsi on r.rept_def_id =rsi.rept_def_id
where rsi.is_scheduled=1 and r.rept_def_id=4 and rsi.client_comp_id=100002 and rsi.REPT_SCHEDULE_STAT_IND=1) A
LEFT OUTER JOIN
( select hi.rptschdlinstance RSI, max(to_char(hi.run_tmstp,'DD-Mon-YYYY HH24:MI:SS')) run from table3 hi group by hi.rptschdlinstance
) B ON A.RSI=B.RSI WHERE to_date(RUN,'DD-Mon-YYYY HH24:MI:SS') > to_date('15-Nov-2006 10:13:38','DD-Mon-YYYY HH24:MI:SS') or RUN IS NULL ORDER BY B.RUN,A.RSI ;

Relation is Table1 to Table2 one to many
Table2 to Table3 one to many.

Thanks in Advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.