-->
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: select ... from ( select
PostPosted: Mon May 02, 2011 3:47 am 
Newbie

Joined: Fri Dec 15, 2006 4:24 am
Posts: 8
good morning mates

I am trying to do a bulk insert from the table A to the table B, and I have to
add a new value in B with the position of the element using a concrete order
in A.

The first thing I tried is to write something like that (HQL):

Code:
insert into A (pos, x, y, z)
select rownum, b.x, b.y, b.z
from B b
order by b.i, b.j


But it doesn't work because setting rownum is done before order.

The way to solve it, is a nested select, something like that (SQL):

Code:
insert into A (pos, x, y, z)
select rownum, b.x, b.y, b.z
from
(
  select x, y, z
  form B
  order i, j
) b


But It looks that there is no equivalence of a nested select in HQL.

I dont want to relay on plain SQL, put if nothing else works, I will have to do.

Any advice? What do you suggest?


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.