update node set parse = ( select o.op||'('||l1.value||')' from pnode o,pnode l1 where o.id = l1.parent and node.id = o.id and not exists ( select o2.id from pnode o2 where o2.parent = o.id and o2.value is null and o2.parse is null) and (select count(*) from pnode oo,pnode ll1 where oo.id = ll1.parent and o.id = oo.id ) = 1 UNION select o.op||'('||l1.value||','||l2.value||')' from pnode o,pnode l1,pnode l2 where o.id = l1.parent and o.id = l2.parent and l1.id < l2.id and node.id = o.id and not exists ( select o2.id from pnode o2 where o2.parent = o.id and o2.value is null and o2.parse is null) and (select count(*) from pnode oo,pnode ll1 where oo.id = ll1.parent and o.id = oo.id ) = 2 UNION select o.op||'('||l1.value||','||l2.value||','||l3.value||')' from pnode o,pnode l1,pnode l2,pnode l3 where o.id = l1.parent and o.id = l2.parent and o.id = l3.parent and l1.id < l2.id and l2.id < l3.id and node.id = o.id and not exists ( select o2.id from pnode o2 where o2.parent = o.id and o2.value is null and o2.parse is null) and (select count(*) from pnode oo,pnode ll1 where oo.id = ll1.parent and o.id = oo.id ) = 3 ) where parse is null ;