我有以下两个更新查询:
update nodes set path = 'A.S' ||
case
when nlevel(path) > nlevel('A.C') then subpath(path, nlevel('A.C'))
when nlevel(path) = nlevel('A.C') then ''
end
where path <@ 'A.C'
update nodes set id = 'A.S' where id = 'A.C'
如果我可以将这些多个更新组合成一个像:
,那将是完美的update nodes set path = 'A.S' ||
case
when nlevel(path) > nlevel('A.C') then subpath(path, nlevel('A.C'))
when nlevel(path) = nlevel('A.C') then ''
end
where path <@ 'A.C'
and
update nodes set id = 'A.S' where id = 'A.C'
我一直在寻找这样做的可能性而无法找到,
实际上可能吗?
感谢任何帮助,谢谢
答案 0 :(得分:2)
update nodes
set path = 'A.S' ||
case
when path <@ 'A.C' and nlevel(path) > nlevel('A.C') then subpath(path, nlevel('A.C'))
when path <@ 'A.C' and nlevel(path) = nlevel('A.C') then ''
else
path
end
, id = case when id = 'A.C' then 'A.S' else id end
where path <@ 'A.C' or id = 'A.C'
尝试交易 - 我没有测试过它!