When you say outside of groovy sql do you mean only sqlplus or does that also include jdbc in plain java ?
Anyways, try and giving your inline view a name and see if that works.
Here I’ve aliased my inline view with a v….
SELECT v.a_id, v.invno, v.hostref, v.goods, v.domain, v.reftime, v.number_row
FROM (SELECT a.id AS a_id, a.invno, m.hostref, f.object_content goods,
FIRST_VALUE (c.master)
OVER (PARTITION BY a.id, a.invno, m.hostref
ORDER BY c.lastref DESC)
AS domain,
FIRST_VALUE ( c.lastref)
OVER (PARTITION BY a.id, a.invno, m.hostref
ORDER BY c.lastref DESC)
AS reftime,
ROW_NUMBER ()
OVER (PARTITION BY a.id, a.invno, m.hostref
ORDER BY c.lastref DESC)
AS number_row
FROM tabowner.inv a
JOIN tabowner.stage m ON a.invno = m.invno
JOIN tabowner.files f ON F.HOSTREF = M.HOSTREF
JOIN tabowner.invbc c ON a.id = c.a_id
WHERE c.master NOT IN ('w', 'b')
AND a.status NOT IN ('D', 'M')
AND F.OBJECT_CATEGORY = 'details') v
WHERE v.number_row = 1
I’ve never used sql.withBatch or stmt.addBatch
But you’ve piqued my interest and I will poke around with it …. later