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?